Skip to content

Commit

Permalink
Update provider and Zone resource documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuolun-citrix committed Nov 3, 2023
1 parent 05fab93 commit 5db04fb
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 36 deletions.
21 changes: 4 additions & 17 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,18 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "citrix Provider"
page_title: "Citrix Provider"
subcategory: ""
description: |-
Interact with Citrix Cloud / Citrix On-Premise Service.
Manage and deploy Citrix resources easily using the Citrix Terraform provider. The provider currently supports both Citrix Virtual Apps & Desktops(CVAD) and Citrix Desktop as a Service (DaaS) solutions. You can automate creation of site setup including host connections, machine catalogs and delivery groups etc for both CVAD and Citrix DaaS. You can deploy resources in Azure, AWS and GCP. The provider is developed and maintained by Citrix. Please note that this provider is still in tech preview.
---

# citrix Provider
# Citrix Provider

Interact with Citrix Cloud / Citrix On-Premise Service.
Manage and deploy Citrix resources easily using the Citrix Terraform provider. The provider currently supports both Citrix Virtual Apps & Desktops(CVAD) and Citrix Desktop as a Service (DaaS) solutions. You can automate creation of site setup including host connections, machine catalogs and delivery groups etc for both CVAD and Citrix DaaS. You can deploy resources in Azure, AWS and GCP. The provider is developed and maintained by Citrix. Please note that this provider is still in **tech preview**.

## Example Usage

```terraform
terraform {
required_version = ">= 1.4.0"
required_providers {
citrix = {
source = "citrix/citrix"
version = ">=0.0.0"
}
}
backend "local" {}
}
# Cloud Provider
provider "citrix" {
customer_id = ""
Expand Down
4 changes: 4 additions & 0 deletions docs/resources/daas_zone.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ page_title: "citrix_daas_zone Resource - citrix"
subcategory: ""
description: |-
Manages a zone.
For cloud DDC, Zones and Cloud Connectors are managed only by Citrix Cloud. Ensure you have a resource location manually created and connectors deployed in it. You may then apply or import the zone using the zone Id.
---

# citrix_daas_zone (Resource)

Manages a zone.
For cloud DDC, Zones and Cloud Connectors are managed only by Citrix Cloud. Ensure you have a resource location manually created and connectors deployed in it. You may then apply or import the zone using the zone Id.

## Example Usage

Expand All @@ -31,10 +33,12 @@ resource "citrix_daas_zone" "example-zone" {
### Required

- `name` (String) Name of the zone.
For Cloud DDC, ensure this matches the name of the existing zone that needs to be used.

### Optional

- `description` (String) Description of the zone.
For Cloud DDC, ensure this matches the description of the existing zone that needs to be used.
- `metadata` (Attributes List) Metadata of the zone. Cannot be modified in DaaS cloud. (see [below for nested schema](#nestedatt--metadata))

### Read-Only
Expand Down
13 changes: 0 additions & 13 deletions examples/provider/provider.tf
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
terraform {
required_version = ">= 1.4.0"

required_providers {
citrix = {
source = "citrix/citrix"
version = ">=0.0.0"
}
}

backend "local" {}
}

# Cloud Provider
provider "citrix" {
customer_id = ""
Expand Down
37 changes: 35 additions & 2 deletions internal/daas/hypervisor_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,11 @@ func (r *hypervisorResource) Create(ctx context.Context, req resource.CreateRequ
body.SetConnectionDetails(connectionDetails)

createHypervisorRequest := r.client.ApiClient.HypervisorsAPIsDAAS.HypervisorsCreateHypervisor(ctx)
createHypervisorRequest = createHypervisorRequest.CreateHypervisorRequestModel(body)
createHypervisorRequest = createHypervisorRequest.CreateHypervisorRequestModel(body).Async(true)

// Create new hypervisor
hypervisor, httpResp, err := citrixdaasclient.AddRequestData(createHypervisorRequest, r.client).Execute()
_, httpResp, err := citrixdaasclient.AddRequestData(createHypervisorRequest, r.client).Execute()

if err != nil {
resp.Diagnostics.AddError(
"Error creating Hypervisor",
Expand All @@ -258,6 +259,38 @@ func (r *hypervisorResource) Create(ctx context.Context, req resource.CreateRequ
return
}

jobId := util.GetJobIdFromHttpResponse(*httpResp)
jobResponseModel, err := r.client.WaitForJob(ctx, jobId, 10)

if err != nil {
resp.Diagnostics.AddError(
"Error creating Hypervisor",
"TransactionId: "+util.GetTransactionIdFromHttpResponse(httpResp)+
"\nJobId: "+jobResponseModel.GetId()+
"\nError message: "+jobResponseModel.GetErrorString(),
)
return
}

if jobResponseModel.GetStatus() != citrixorchestration.JOBSTATUS_COMPLETE {
errorDetail := "TransactionId: " + util.GetTransactionIdFromHttpResponse(httpResp) +
"\nJobId: " + jobResponseModel.GetId()

if jobResponseModel.GetStatus() == citrixorchestration.JOBSTATUS_FAILED {
errorDetail = errorDetail + "\nError message: " + jobResponseModel.GetErrorString()
}

resp.Diagnostics.AddError(
"Error creating Hypervisor",
errorDetail,
)
}

hypervisor, err := GetHypervisor(ctx, r.client, &resp.Diagnostics, plan.Name.ValueString())
if err != nil {
return
}

// Map response body to schema and populate Computed attribute values
plan = plan.RefreshPropertyValues(hypervisor)

Expand Down
6 changes: 3 additions & 3 deletions internal/daas/zone_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (r *zoneResource) Metadata(_ context.Context, req resource.MetadataRequest,
// Schema defines the schema for the data source.
func (r *zoneResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
resp.Schema = schema.Schema{
Description: "Manages a zone.",
Description: "Manages a zone.\nFor cloud DDC, Zones and Cloud Connectors are managed only by Citrix Cloud. Ensure you have a resource location manually created and connectors deployed in it. You may then apply or import the zone using the zone Id.",
Attributes: map[string]schema.Attribute{
"id": schema.StringAttribute{
Description: "GUID identifier of the zone.",
Expand All @@ -52,11 +52,11 @@ func (r *zoneResource) Schema(_ context.Context, _ resource.SchemaRequest, resp
},
},
"name": schema.StringAttribute{
Description: "Name of the zone.",
Description: "Name of the zone.\nFor Cloud DDC, ensure this matches the name of the existing zone that needs to be used.",
Required: true,
},
"description": schema.StringAttribute{
Description: "Description of the zone.",
Description: "Description of the zone.\nFor Cloud DDC, ensure this matches the description of the existing zone that needs to be used.",
Optional: true,
},
"metadata": schema.ListNestedAttribute{
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (p *citrixProvider) Metadata(_ context.Context, _ provider.MetadataRequest,
// Schema defines the provider-level schema for configuration data.
func (p *citrixProvider) Schema(_ context.Context, _ provider.SchemaRequest, resp *provider.SchemaResponse) {
resp.Schema = schema.Schema{
Description: "Interact with Citrix Cloud / Citrix On-Premise Service.",
Description: "Manage and deploy Citrix resources easily using the Citrix Terraform provider. The provider currently supports both Citrix Virtual Apps & Desktops(CVAD) and Citrix Desktop as a Service (DaaS) solutions. You can automate creation of site setup including host connections, machine catalogs and delivery groups etc for both CVAD and Citrix DaaS. You can deploy resources in Azure, AWS and GCP. The provider is developed and maintained by Citrix. Please note that this provider is still in **tech preview**.",
Attributes: map[string]schema.Attribute{
"hostname": schema.StringAttribute{
Description: "Host name / base URL of Citrix DaaS service. " + "<br />" +
Expand Down

0 comments on commit 5db04fb

Please sign in to comment.