Skip to content

Commit

Permalink
v1.0.5-pre-release
Browse files Browse the repository at this point in the history
  • Loading branch information
yashbhokare-citrix committed Oct 3, 2024
1 parent b0bfc0e commit 1e66466
Show file tree
Hide file tree
Showing 35 changed files with 1,085 additions and 42 deletions.
44 changes: 44 additions & 0 deletions docs/resources/wem_configuration_set.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "citrix_wem_configuration_set Resource - citrix"
subcategory: "WEM"
description: |-
Manages configuration sets within a WEM deployment.
---

# citrix_wem_configuration_set (Resource)

Manages configuration sets within a WEM deployment.

## Example Usage

```terraform
resource "citrix_wem_configuration_set" "example-config-set"{
name = "example config set"
description = "example WEM configuration set"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) Name of the configuration site. WEM Site Name should be unique.

### Optional

- `description` (String) Description of the configuration site. Default value is empty string.

### Read-Only

- `id` (String) Identifier of the configuration site.

## Import

Import is supported using the following syntax:

```shell
# WEM Configuration Set can be imported by specifying the ID
terraform import citrix_wem_configuration_set.example-config-set 0000
```
43 changes: 43 additions & 0 deletions docs/resources/wem_directory_object.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "citrix_wem_directory_object Resource - citrix"
subcategory: "WEM"
description: |-
Manages machine-level AD objects within a WEM deployment.
---

# citrix_wem_directory_object (Resource)

Manages machine-level AD objects within a WEM deployment.

## Example Usage

```terraform
resource "citrix_wem_directory_object" "example-directory-object" {
configuration_set_id = citrix_wem_configuration_set.example-config-set.id
machine_catalog_id = citrix_machine_catalog.example-machine-catalog.id
enabled = true
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `configuration_set_id` (Number) Identifier of the site to which the machine-level AD object belongs.
- `enabled` (Boolean) Indicates whether the machine-level AD object is enabled.
- `machine_catalog_id` (String) GUID identifier of the machine catalog.

### Read-Only

- `id` (String) Identifier of the directory object.

## Import

Import is supported using the following syntax:

```shell
# WEM Directory Object can be imported by specifying the ID
terraform import citrix_wem_directory_object.example-directory-object 0000
```
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.22.0
toolchain go1.23.1

require (
github.com/citrix/citrix-daas-rest-go v1.0.5
github.com/citrix/citrix-daas-rest-go v1.0.6-preview
github.com/google/uuid v1.6.0
github.com/hashicorp/go-azure-helpers v0.71.0
github.com/hashicorp/go-multierror v1.1.1
Expand Down Expand Up @@ -75,8 +75,8 @@ require (
golang.org/x/text v0.18.0 // indirect
golang.org/x/tools v0.25.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240924160255-9d4c2d233b61 // indirect
google.golang.org/grpc v1.67.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
google.golang.org/grpc v1.67.1 // indirect
google.golang.org/protobuf v1.34.2 // indirect
)

Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQ
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA=
github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8=
github.com/citrix/citrix-daas-rest-go v1.0.5 h1:zDOoydXQq4jQ3fObZypsBG6ZJxyHIcHrS4eg6kJzlZ0=
github.com/citrix/citrix-daas-rest-go v1.0.5/go.mod h1:4Me0VHpyxMYfPwpU2XWV0jOE2Jdz8MHNpge3MLD5B2E=
github.com/citrix/citrix-daas-rest-go v1.0.6-preview h1:+wIJMiU6uz3ugHyZ61Ijh/h3mFCNSzanj4DiOLKj1Ho=
github.com/citrix/citrix-daas-rest-go v1.0.6-preview/go.mod h1:4Me0VHpyxMYfPwpU2XWV0jOE2Jdz8MHNpge3MLD5B2E=
github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU=
github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA=
github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg=
Expand Down Expand Up @@ -269,10 +269,10 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM=
google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240924160255-9d4c2d233b61 h1:N9BgCIAUvn/M+p4NJccWPWb3BWh88+zyL0ll9HgbEeM=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240924160255-9d4c2d233b61/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
google.golang.org/grpc v1.67.0 h1:IdH9y6PF5MPSdAntIcpjQ+tXO41pcQsfZV2RxtQgVcw=
google.golang.org/grpc v1.67.0/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f h1:cUMEy+8oS78BWIH9OWazBkzbr090Od9tWBNtZHkOhf0=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E=
google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
Expand Down
2 changes: 1 addition & 1 deletion internal/daas/admin_folder/admin_folder_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (d *AdminFolderDataSource) Read(ctx context.Context, req datasource.ReadReq
adminFolderIdOrPath = data.Id.ValueString()
}
if data.Path.ValueString() != "" {
adminFolderIdOrPath = data.Path.ValueString()
adminFolderIdOrPath = data.Path.ValueString() + "\\"
adminFolderIdOrPath = strings.ReplaceAll(adminFolderIdOrPath, "\\", "|")
}

Expand Down
8 changes: 7 additions & 1 deletion internal/daas/admin_folder/admin_folder_data_source_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package admin_folder

import (
"context"
"regexp"
"strings"

citrixorchestration "github.com/citrix/citrix-daas-rest-go/citrixorchestration"
Expand Down Expand Up @@ -43,6 +44,10 @@ func (AdminFolderDataSourceModel) GetSchema() schema.Schema {
"path": schema.StringAttribute{
Description: "Path to the admin folder.",
Optional: true,
Validators: []validator.String{
stringvalidator.RegexMatches(regexp.MustCompile(util.AdminFolderPathWithBackslashRegex), "Admin Folder Path must not start or end with a backslash"),
stringvalidator.RegexMatches(regexp.MustCompile(util.AdminFolderPathSpecialCharactersRegex), "Admin Folder Path must not contain any of the following special characters: / ; : # . * ? = < > | [ ] ( ) { } \" ' ` ~ "),
},
},
"name": schema.StringAttribute{
Description: "Name of the admin folder.",
Expand Down Expand Up @@ -82,7 +87,7 @@ func (r AdminFolderDataSourceModel) RefreshPropertyValues(ctx context.Context, d
r.Id = types.StringValue(adminFolder.GetId())
r.Name = types.StringValue(adminFolder.GetName())

r.Path = types.StringValue(adminFolder.GetPath())
r.Path = types.StringValue(strings.TrimSuffix(adminFolder.GetPath(), "\\"))

adminFolderTypes := []string{}
adminFolderMetadata := adminFolder.GetMetadata()
Expand All @@ -94,6 +99,7 @@ func (r AdminFolderDataSourceModel) RefreshPropertyValues(ctx context.Context, d
r.Type = adminFolderTypeSet

var parentPath = strings.TrimSuffix(adminFolder.GetPath(), adminFolder.GetName()+"\\")
parentPath = strings.TrimSuffix(parentPath, "\\")
if parentPath != "" {
r.ParentPath = types.StringValue(parentPath)
} else {
Expand Down
8 changes: 6 additions & 2 deletions internal/daas/admin_folder/admin_folder_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ func (r *adminFolderResource) Create(ctx context.Context, req resource.CreateReq
// Generate API request body from plan
var createAdminFolderRequest citrixorchestration.CreateAdminFolderRequestModel
createAdminFolderRequest.SetName(plan.Name.ValueString())
createAdminFolderRequest.SetPath(plan.ParentPath.ValueString())
parentPath := plan.ParentPath.ValueString()
if parentPath != "" {
parentPath = parentPath + "\\"
}
createAdminFolderRequest.SetPath(parentPath)

adminFolderTypesArray, err := getAdminFolderObjectIdentifierArrayFromTypeSet(ctx, &resp.Diagnostics, plan.Name.ValueString(), plan.Type)
if err != nil {
Expand Down Expand Up @@ -155,7 +159,7 @@ func (r *adminFolderResource) Update(ctx context.Context, req resource.UpdateReq
editAdminFolderRequestBody.SetName(plan.Name.ValueString())

var parentPath = strings.TrimSuffix(adminFolderResource.GetPath(), adminFolderResource.GetName()+"\\")
if plan.ParentPath.ValueString() != parentPath {
if plan.ParentPath.ValueString() != strings.TrimSuffix(parentPath, "\\") {
editAdminFolderRequestBody.SetParent(plan.ParentPath.ValueString())
}

Expand Down
8 changes: 7 additions & 1 deletion internal/daas/admin_folder/admin_folder_resource_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package admin_folder

import (
"context"
"regexp"
"strings"

citrixorchestration "github.com/citrix/citrix-daas-rest-go/citrixorchestration"
Expand Down Expand Up @@ -43,6 +44,10 @@ func (AdminFolderResourceModel) GetSchema() schema.Schema {
"parent_path": schema.StringAttribute{
Description: "Path of the parent admin folder.",
Optional: true,
Validators: []validator.String{
stringvalidator.RegexMatches(regexp.MustCompile(util.AdminFolderPathWithBackslashRegex), "Admin Folder Path must not start or end with a backslash"),
stringvalidator.RegexMatches(regexp.MustCompile(util.AdminFolderPathSpecialCharactersRegex), "Admin Folder Path must not contain any of the following special characters: / ; : # . * ? = < > | [ ] ( ) { } \" ' ` ~ "),
},
},
"type": schema.SetAttribute{
ElementType: types.StringType,
Expand Down Expand Up @@ -80,7 +85,7 @@ func (r AdminFolderResourceModel) RefreshPropertyValues(ctx context.Context, dia
r.Name = types.StringValue(adminFolder.GetName())

// Set optional values
r.Path = types.StringValue(adminFolder.GetPath())
r.Path = types.StringValue(strings.TrimSuffix(adminFolder.GetPath(), "\\"))

adminFolderTypes := []string{}
adminFolderMetadata := adminFolder.GetMetadata()
Expand All @@ -92,6 +97,7 @@ func (r AdminFolderResourceModel) RefreshPropertyValues(ctx context.Context, dia
r.Type = adminFolderTypeSet

var parentPath = strings.TrimSuffix(adminFolder.GetPath(), adminFolder.GetName()+"\\")
parentPath = strings.TrimSuffix(parentPath, "\\")
if parentPath != "" {
r.ParentPath = types.StringValue(parentPath)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package application
import (
"context"
"regexp"
"strings"

citrixorchestration "github.com/citrix/citrix-daas-rest-go/citrixorchestration"
citrixdaasclient "github.com/citrix/citrix-daas-rest-go/client"
Expand Down Expand Up @@ -117,6 +118,10 @@ func (ApplicationGroupResourceModel) GetSchema() schema.Schema {
"application_group_folder_path": schema.StringAttribute{
Description: "The path of the folder in which the application group is located.",
Optional: true,
Validators: []validator.String{
stringvalidator.RegexMatches(regexp.MustCompile(util.AdminFolderPathWithBackslashRegex), "Admin Folder Path must not start or end with a backslash"),
stringvalidator.RegexMatches(regexp.MustCompile(util.AdminFolderPathSpecialCharactersRegex), "Admin Folder Path must not contain any of the following special characters: / ; : # . * ? = < > | [ ] ( ) { } \" ' ` ~ "),
},
},
"tenants": schema.SetAttribute{
ElementType: types.StringType,
Expand Down Expand Up @@ -185,7 +190,7 @@ func (r ApplicationGroupResourceModel) RefreshPropertyValues(ctx context.Context
r.InheritedScopes = util.StringArrayToStringSet(ctx, diagnostics, inheritedScopeIds)

adminFolder := applicationGroup.GetAdminFolder()
adminFolderPath := adminFolder.GetName()
adminFolderPath := strings.TrimSuffix(adminFolder.GetName(), "\\")
if adminFolderPath != "" {
r.ApplicationGroupFolderPath = types.StringValue(adminFolderPath)
} else {
Expand Down
4 changes: 2 additions & 2 deletions internal/daas/application/application_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (r *applicationResource) Create(ctx context.Context, req resource.CreateReq

// If the application is present in an application folder, we specify the name in this format: {application folder path plus application name}.For example, FolderName1|FolderName2|ApplicationName.
if plan.ApplicationFolderPath.ValueString() != "" {
applicationName = strings.ReplaceAll(plan.ApplicationFolderPath.ValueString(), "\\", "|") + applicationName
applicationName = strings.ReplaceAll(plan.ApplicationFolderPath.ValueString(), "\\", "|") + "|" + applicationName
}

application, err := getApplication(ctx, r.client, &resp.Diagnostics, applicationName)
Expand Down Expand Up @@ -399,7 +399,7 @@ func checkIfApplicationFolderPathExist(ctx context.Context, client *citrixdaascl
return true
}

tempFolderPath := strings.ReplaceAll(applicationFolderPath, "\\", "|")
tempFolderPath := strings.ReplaceAll(applicationFolderPath, "\\", "|") + "|"
appFolderExistRequest := client.ApiClient.ApplicationFoldersAPIsDAAS.ApplicationFoldersCheckApplicationFolderPathExists(ctx, tempFolderPath)
httpResp, err := citrixdaasclient.AddRequestData(appFolderExistRequest, client).Execute()
if err != nil {
Expand Down
11 changes: 9 additions & 2 deletions internal/daas/application/application_resource_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"context"
"regexp"
"sort"
"strings"

citrixorchestration "github.com/citrix/citrix-daas-rest-go/citrixorchestration"
"github.com/citrix/terraform-provider-citrix/internal/util"
Expand Down Expand Up @@ -166,6 +167,10 @@ func (ApplicationResourceModel) GetSchema() schema.Schema {
"application_folder_path": schema.StringAttribute{
Description: "The application folder path in which the application should be created.",
Optional: true,
Validators: []validator.String{
stringvalidator.RegexMatches(regexp.MustCompile(util.AdminFolderPathWithBackslashRegex), "Admin Folder Path must not start or end with a backslash"),
stringvalidator.RegexMatches(regexp.MustCompile(util.AdminFolderPathSpecialCharactersRegex), "Admin Folder Path must not contain any of the following special characters: / ; : # . * ? = < > | [ ] ( ) { } \" ' ` ~ "),
},
},
"icon": schema.StringAttribute{
Description: "The Id of the icon to be associated with the application.",
Expand Down Expand Up @@ -229,8 +234,10 @@ func (r ApplicationResourceModel) RefreshPropertyValues(ctx context.Context, dia
r.ApplicationCategoryPath = types.StringValue(application.GetClientFolder())

// Set optional values
if *application.GetApplicationFolder().Name.Get() != "" {
r.ApplicationFolderPath = types.StringValue(*application.GetApplicationFolder().Name.Get())
adminFolder := application.GetApplicationFolder()
adminFolderPath := strings.TrimSuffix(adminFolder.GetName(), "\\")
if adminFolderPath != "" {
r.ApplicationFolderPath = types.StringValue(adminFolderPath)
} else {
r.ApplicationFolderPath = types.StringNull()
}
Expand Down
9 changes: 8 additions & 1 deletion internal/daas/delivery_group/delivery_group_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package delivery_group

import (
"context"
"strings"

citrixdaasclient "github.com/citrix/citrix-daas-rest-go/client"
"github.com/citrix/terraform-provider-citrix/internal/util"
Expand Down Expand Up @@ -61,7 +62,13 @@ func (d *DeliveryGroupDataSource) Read(ctx context.Context, req datasource.ReadR

// Get refreshed delivery group state from Orchestration
deliveryGroupName := data.Name.ValueString()
getDeliveryGroupRequest := d.client.ApiClient.DeliveryGroupsAPIsDAAS.DeliveryGroupsGetDeliveryGroup(ctx, deliveryGroupName)
deliveryGroupPath := strings.ReplaceAll(data.DeliveryGroupFolderPath.ValueString(), "\\", "|")
if deliveryGroupPath != "" {
deliveryGroupPath = deliveryGroupPath + "|" + deliveryGroupName
} else {
deliveryGroupPath = deliveryGroupName
}
getDeliveryGroupRequest := d.client.ApiClient.DeliveryGroupsAPIsDAAS.DeliveryGroupsGetDeliveryGroup(ctx, deliveryGroupPath)
deliveryGroup, httpResp, err := citrixdaasclient.AddRequestData(getDeliveryGroupRequest, d.client).Execute()
if err != nil {
resp.Diagnostics.AddError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ package delivery_group

import (
"context"
"regexp"
"strings"

"github.com/citrix/citrix-daas-rest-go/citrixorchestration"
"github.com/citrix/terraform-provider-citrix/internal/daas/vda"
"github.com/citrix/terraform-provider-citrix/internal/util"
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
)

Expand Down Expand Up @@ -38,6 +42,10 @@ func (DeliveryGroupDataSourceModel) GetSchema() schema.Schema {
"delivery_group_folder_path": schema.StringAttribute{
Description: "The path to the folder in which the delivery group is located.",
Optional: true,
Validators: []validator.String{
stringvalidator.RegexMatches(regexp.MustCompile(util.AdminFolderPathWithBackslashRegex), "Admin Folder Path must not start or end with a backslash"),
stringvalidator.RegexMatches(regexp.MustCompile(util.AdminFolderPathSpecialCharactersRegex), "Admin Folder Path must not contain any of the following special characters: / ; : # . * ? = < > | [ ] ( ) { } \" ' ` ~ "),
},
},
"vdas": schema.ListNestedAttribute{
Description: "The VDAs associated with the delivery group.",
Expand All @@ -63,7 +71,7 @@ func (r DeliveryGroupDataSourceModel) RefreshPropertyValues(ctx context.Context,
r.Name = types.StringValue(deliveryGroup.GetName())

adminFolder := deliveryGroup.GetAdminFolder()
adminFolderPath := adminFolder.GetName()
adminFolderPath := strings.TrimSuffix(adminFolder.GetName(), "\\")
if adminFolderPath != "" {
r.DeliveryGroupFolderPath = types.StringValue(adminFolderPath)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,10 @@ func (DeliveryGroupResourceModel) GetSchema() schema.Schema {
"delivery_group_folder_path": schema.StringAttribute{
Description: "The path of the folder in which the delivery group is located.",
Optional: true,
Validators: []validator.String{
stringvalidator.RegexMatches(regexp.MustCompile(util.AdminFolderPathWithBackslashRegex), "Admin Folder Path must not start or end with a backslash"),
stringvalidator.RegexMatches(regexp.MustCompile(util.AdminFolderPathSpecialCharactersRegex), "Admin Folder Path must not contain any of the following special characters: / ; : # . * ? = < > | [ ] ( ) { } \" ' ` ~ "),
},
},
"tenants": schema.SetAttribute{
ElementType: types.StringType,
Expand Down Expand Up @@ -1186,7 +1190,7 @@ func (r DeliveryGroupResourceModel) RefreshPropertyValues(ctx context.Context, d
}

adminFolder := deliveryGroup.GetAdminFolder()
adminFolderPath := adminFolder.GetName()
adminFolderPath := strings.TrimSuffix(adminFolder.GetName(), "\\")
if adminFolderPath != "" {
r.DeliveryGroupFolderPath = types.StringValue(adminFolderPath)
} else {
Expand Down
Loading

0 comments on commit 1e66466

Please sign in to comment.