diff --git a/Makefile b/Makefile index 307466a..8c782be 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ TEST?=$$(go list ./... | grep -v 'vendor') HOSTNAME=github.com NAMESPACE=KopiCloud-AD-API -NAME=terraform-provider-ad +NAME=ad BINARY=terraform-provider-${NAME} VERSION=$(shell git describe --tags) BUIDL_DATE=$(shell date +%Y-%m-%d) diff --git a/docs/resources/kopicloud_user.md b/docs/resources/kopicloud_user.md index 0eab66b..1cf06ef 100644 --- a/docs/resources/kopicloud_user.md +++ b/docs/resources/kopicloud_user.md @@ -17,6 +17,7 @@ Element to create, update, delete Users from Active Directory ### Required +- `new_password` (String) - `password` (String) - `username` (String) diff --git a/docs/resources/kopicloud_user_password_reset.md b/docs/resources/kopicloud_user_password_reset.md deleted file mode 100644 index 7a9dae5..0000000 --- a/docs/resources/kopicloud_user_password_reset.md +++ /dev/null @@ -1,74 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "kopicloud_user_password_reset Resource - kopicloud-ad-tf-provider" -subcategory: "" -description: |- - Element to create, update, delete Users from Active Directory ---- - -# kopicloud_user_password_reset (Resource) - -Element to create, update, delete Users from Active Directory - - - - -## Schema - -### Required - -- `new_password` (String) -- `username` (String) - -### Optional - -- `change_password_net_logon` (Boolean) -- `show_fields` (String) - -### Read-Only - -- `id` (String) The ID of this resource. -- `result` (List of Object) Single Element List of User (see [below for nested schema](#nestedatt--result)) - - -### Nested Schema for `result` - -Read-Only: - -- `change_password_next_logon` (Boolean) -- `city` (String) -- `company` (String) -- `country` (String) -- `department` (String) -- `description` (String) -- `display_name` (String) -- `email_address` (String) -- `first_name` (String) -- `home_folder_directory` (String) -- `home_folder_drive` (String) -- `home_folder_path` (String) -- `home_phone` (String) -- `initials` (String) -- `job_title` (String) -- `last_name` (String) -- `manager` (String) -- `middle_name` (String) -- `mobile_phone` (String) -- `office` (String) -- `office_phone` (String) -- `ou_path` (String) -- `postal_code` (String) -- `profile_logon_script` (String) -- `profile_path` (String) -- `rds_allow_logon` (Boolean) -- `rds_connect_drive` (Boolean) -- `rds_home_folder_drive` (String) -- `rds_home_folder_path` (String) -- `rds_profile_path` (String) -- `sam_username` (String) -- `state` (String) -- `street_address` (String) -- `street_po_box` (String) -- `username` (String) - - diff --git a/example/main.tf b/example/main.tf new file mode 100644 index 0000000..bcff3f9 --- /dev/null +++ b/example/main.tf @@ -0,0 +1,349 @@ +terraform { + required_providers { + kopicloud = { + source = "github.com/KopiCloud-AD-API/ad" + } + } +} + +provider "kopicloud" { + host = "https://labapi.kopicloud-ad-api.com" + token = "Basic b3NjYXI6UzFsdjNyQnVsbDN0" +} + +# data "kopicloud_computers" "test" { +# oupath= "OU=Domain Controllers,DC=kopicloud,DC=local" +# recursive=true +# } + +# # Returns all computers +# output "computers_list" { +# description = "Existing computers" +# value = data.kopicloud_computers.test +# } + + +# data "kopicloud_computer_list" "test" {} + +# # Returns all computers +# output "all_computers_list" { +# description = "Existing computers" +# value = data.kopicloud_computer_list.test.result +# } + +# data "kopicloud_ou_list" "test" {} + +# # Returns all computers +# output "all_ous_list" { +# description = "Existing OUs" +# value = data.kopicloud_ou_list.test.result +# } + + +# data "kopicloud_computer_list" "by_ou" { +# ou_path = "OU=Domain Controllers,DC=kopicloud,DC=local" +# } + +# # Returns all computers +# output "ou_computers_list" { +# description = "Existing computers" +# value = data.kopicloud_computer_list.by_ou.result +# } + +# data "kopicloud_computer_list" "by_name" { +# ad_computer_name = "BIG-WOPER" +# } + +# # Returns all computers +# output "by_name_computers_list" { +# description = "Existing computers" +# value = data.kopicloud_computer_list.by_name.result +# } + + +# data "kopicloud_group_list" "test" {} + +# # Returns all ADGroups +# output "kopicloud_all_groups" { +# description = "Existing Groups" +# value = data.kopicloud_group_list.test +# } + +# data "kopicloud_security_group_list" "test" {} + +# # Returns all ADGroups +# output "kopicloud_all_security_groups" { +# description = "Existing Security Groups" +# value = data.kopicloud_security_group_list.test +# } + +# data "kopicloud_distribution_group_list" "test" {} + +# # Returns all ADGroups +# output "kopicloud_all_distribution_groups" { +# description = "Existing Distribution Groups" +# value = data.kopicloud_distribution_group_list.test +# } + +# data "kopicloud_all_ad_users" "test" {} + +# # Returns all ADUsers +# output "kopicloud_all_ad_users" { +# description = "Existing AD Users" +# value = data.kopicloud_all_ad_users.test +# } + +# data "kopicloud_all_ous" "test" {} + +# # Returns all ous +# output "all_ous_list" { +# description = "Existing OUs" +# value = data.kopicloud_all_ous.test +# } + + +# data "kopicloud_dns_a_records_list" "by_ip" { +# ip_address = "10.20.1.241" +# } + +# # Returns all DNS A Records +# output "by_ip_dns_a_records" { +# description = "Existing DNS A Records" +# value = data.kopicloud_dns_a_records_list.by_ip +# } + +# data "kopicloud_dns_a_records_list" "by_zone" { +# zone_name = "kopicloud.local" +# } + +# # Returns all DNS A Records +# output "by_zone_dns_a_records" { +# description = "Existing DNS A Records" +# value = data.kopicloud_dns_a_records_list.by_zone +# } + + +# data "kopicloud_dns_a_records_list" "one" { +# hostname = "computer1975" +# ip_address = "10.20.1.241" +# zone_name = "kopicloud.local" +# } + +# # Returns all DNS A Records +# output "some_dns_a_records" { +# description = "Existing DNS A Records" +# value = data.kopicloud_dns_a_records_list.one +# } + +# data "kopicloud_dns_a_records_list" "all" {} + +# # Returns all DNS A Records +# output "all_dns_a_records" { +# description = "Existing DNS A Records" +# value = data.kopicloud_dns_a_records_list.all +# } + +# data "kopicloud_dns_aaaa_records_list" "test" {} + +# # Returns all DNS AAAA Records +# output "all_dns_aaaa_records" { +# description = "Existing DNS AAAA Records" +# value = data.kopicloud_dns_aaaa_records_list.test.result +# } + +# data "kopicloud_dns_cname_records_list" "test" {} + +# # Returns all DNS CNAME Records +# output "all_dns_cname_records" { +# description = "Existing DNS CName Records" +# value = data.kopicloud_dns_cname_records_list.test.result +# } + +# data "kopicloud_all_dns_zones" "test" {} + +# # Returns all DNS CNAME Records +# output "all_dns_zones" { +# description = "Existing DNS Zones" +# value = data.kopicloud_all_dns_zones.test +# } + +# resource "kopicloud_computer" "test" { +# ad_computer_name = "BIG-WOPER" +# ou_path= "OU=Domain Controllers,DC=kopicloud,DC=local" +# } + +# output "computer" { +# description = "Created Computer" +# value = resource.kopicloud_computer.test +# } + + +# resource "kopicloud_distribution_group" "test" { +# name = "my-new-distro-group" +# scope = "Global" +# description = "This is a very cool distribution group" +# email = "distribution@kopicloud.com" +# ou_path = "OU=Domain Controllers,DC=kopicloud,DC=local" +# } + +# output "distribution_group" { +# description = "Created Security Group" +# value = resource.kopicloud_distribution_group.test +# } + +# resource "kopicloud_ou" "test" { +# ou_name = "kopicloud-13" +# ou_path = "OU=Domain Controllers,DC=kopicloud,DC=local" +# description = "This is a very cool organization with improved description" +# protected = false +# } + +# output "ou" { +# description = "Created OU" +# value = resource.kopicloud_ou.test +# } + +# resource "kopicloud_dns_a_record" "test" { +# hostname = "computer1978" +# ip_address = "10.20.1.241" +# zone_name = "kopicloud.local" +# } + +# output "dns_a_record" { +# description = "Created DNS A Record" +# value = resource.kopicloud_dns_a_record.test +# } + +# resource "kopicloud_dns_aaaa_record" "test" { +# hostname = "computer-AAAA-6" +# ipv6_address = "2001:db8:3333:4444:5555:6666:7777:8889" +# zone_name = "kopicloud.local" +# } + +# output "dns_aaaa_record" { +# description = "Created DNS AAAA Record" +# value = resource.kopicloud_dns_aaaa_record.test +# } + +# resource "kopicloud_dns_cname_record" "test" { +# hostname = "computer1969" +# hostname_alias = "computer1969 _alias" +# zone_name = "kopicloud.local" +# } + +# output "dns_cname_record" { +# description = "Created DNS CName Record" +# value = resource.kopicloud_dns_cname_record.test.result +# } + +# resource "kopicloud_dns_lookup_zone" "test" { +# zone_name = "my-zone-returns" +# } + +# output "dns_lookup_zone" { +# description = "Created DNS Lookup zone" +# value = resource.kopicloud_dns_lookup_zone.test +# } + +# resource "kopicloud_dns_reverse_lookup_zone" "test" { +# network_id = "192.169.50.0/24" +# } + +# output "dns_reverse_lookup_zone" { +# description = "Created DNS Reverse Lookup zone" +# value = resource.kopicloud_dns_reverse_lookup_zone.test +# } + +# data "kopicloud_dns_lookup_zone_list" "test" {} + +# # Returns all computers +# output "all_dns_looup_zones_list" { +# description = "Existing Lookup Zones" +# value = data.kopicloud_dns_lookup_zone_list.test.result +# } + +# data "kopicloud_dns_reverse_lookup_zone_list" "test" {} + +# # Returns all computers +# output "all_dns_reverse_looup_zones_list" { +# description = "Existing Reverse Lookup Zones" +# value = data.kopicloud_dns_reverse_lookup_zone_list.test.result +# } + + +# data "kopicloud_dns_zone_list" "test" {} + +# # Returns all computers +# output "all_dns_zones_list" { +# description = "Existing Reverse Lookup Zones" +# value = data.kopicloud_dns_zone_list.test.result +# } + + +# data "kopicloud_dns_a_records_list" "test_hostname" { +# hostname = "tito2" +# } + +# output "kopicloud_dns_a_records_list" { +# description = "Existing DNS A Records" +# value = data.kopicloud_dns_a_records_list.test_hostname.result +# } + +# data "kopicloud_group_membership_list" "test" { +# user_name = "guillermo" +# } + +# # Returns all ADGroups for a User +# output "kopicloud_group_membership_list" { +# description = "AD Groups for user" +# value = data.kopicloud_group_membership_list.test.result +# } + +# resource "kopicloud_computer_cleanup" "test" { +# days = 1 +# ou_path = "OU=Domain Controllers,DC=kopicloud,DC=local" +# recursive = true +# } + +# output "computer_cleanup" { +# description = "Computers To CleanUp" +# value = resource.kopicloud_computer_cleanup.test +# } + +# data "kopicloud_user_list" "test" { +# show_fields = "firstName,lastName,displayName" +# } + +# # Returns all ADUsers +# output "kopicloud_all_users" { +# description = "Existing AD Users" +# value = data.kopicloud_user_list.test +# } + +resource "kopicloud_user" "test" { + username = "oforero9" + password = "vMD48X6Vdyj49j8%" + first_name = "Oscar" + last_name = "Forero" + show_fields = "Username,FirstName,LastName" +} + +output "user" { + description = "Created User" + value = resource.kopicloud_user.test.result +} + +# Create a Global Distribution Group +resource "kopicloud_distribution_group" "test_distribution_global" { + name = "kopicloud-europe-distribution-group-blue-2" + scope = "Global" + description = "This is a very cool Global distribution group" + email = "europe.distribution@kopicloud.com" + ou_path = "CN=Users,DC=kopicloud,DC=local" +} + +# Returns Created Global Distribution Group +output "OUTPUT_global_distribution_group" { + description = "Created Global Distribution Group" + value = resource.kopicloud_distribution_group.test_distribution_global +} diff --git a/generator-inputs/user.json b/generator-inputs/user.json index e864694..73e693d 100644 --- a/generator-inputs/user.json +++ b/generator-inputs/user.json @@ -149,6 +149,11 @@ "type": "schema.TypeString", "optional": true }, + { + "name": "new_password", + "type": "schema.TypeString", + "required": true + }, { "name": "change_password_net_logon", "type": "schema.TypeBool", @@ -372,6 +377,47 @@ "terraform_field": "result", "api_to_terraform_id": "getId_for_User" } + }, + { + "required_inputs": ["new_password"], + "api_function": { + "name": "PostApiADUserUsernameResetPasswordWithResponse", + "isPointer": true, + "arguments": [ + { + "name": "username", + "type": "string" + } + ], + "params": { + "name": "PostApiADUserUsernameResetPasswordParams", + "fields": [ + { + "api_name": "NewPassword", + "name": "new_password", + "type": "*string" + }, + { + "api_name": "ChangePassword", + "name": "change_password_net_logon", + "type": "*bool" + }, + { + "api_name": "ShowFields", + "name": "show_fields", + "type": "*string" + } + ] + } + }, + "result": { + "msg_field": "Output", + "result_field": "Result", + "api_to_terraform": "UserToTerraform", + "result_wrapper": "wrapInArray", + "terraform_field": "result", + "api_to_terraform_id": "getId_for_User" + } } ], "delete": { diff --git a/main.go b/main.go index dfa0c89..ed865f7 100644 --- a/main.go +++ b/main.go @@ -55,7 +55,7 @@ import ( //go:generate openapi-terraform-provider-generator datasource-read --api github.com/KopiCloud-AD-API/terraform-provider-ad/api -p provider -o provider/kopicloud.user-data.gen.go -i generator-inputs/user.json // Generate the Code for User Password Reset -//go:generate openapi-terraform-provider-generator resource-crud --api github.com/KopiCloud-AD-API/terraform-provider-ad/api -p provider -o provider/kopicloud.user-password-reset-crud.gen.go -i generator-inputs/user_password_reset.json +//:generate openapi-terraform-provider-generator resource-crud --api github.com/KopiCloud-AD-API/terraform-provider-ad/api -p provider -o provider/kopicloud.user-password-reset-crud.gen.go -i generator-inputs/user_password_reset.json // Generate the Code for the DNS A Records //go:generate openapi-terraform-provider-generator resource-crud --api github.com/KopiCloud-AD-API/terraform-provider-ad/api -p provider -o provider/kopicloud.dns_a_record-crud.gen.go -i generator-inputs/dns_a_record.json @@ -78,7 +78,7 @@ import ( //go:generate openapi-terraform-provider-generator datasource-read --api github.com/KopiCloud-AD-API/terraform-provider-ad/api -p provider -o provider/kopicloud.dns_reverse_lookup_zone-data.gen.go -i generator-inputs/dns_reverse_lookup_zone.json // Generate the schemas for the resources (should list all the JSON files for which resources were generated) -//go:generate openapi-terraform-provider-generator resource-schemas --api github.com/KopiCloud-AD-API/terraform-provider-ad/api -p provider -o provider/kopicloud.resources-schemas.gen.go -i generator-inputs/computer.json -i generator-inputs/computer_cleanup.json -i generator-inputs/organizational_unit.json -i generator-inputs/dns_a_record.json -i generator-inputs/dns_aaaa_record.json -i generator-inputs/dns_cname_record.json -i generator-inputs/dns_lookup_zone.json -i generator-inputs/dns_reverse_lookup_zone.json -i generator-inputs/security_group.json -i generator-inputs/distribution_group.json -i generator-inputs/group_membership.json -i generator-inputs/user.json -i generator-inputs/user_password_reset.json +//go:generate openapi-terraform-provider-generator resource-schemas --api github.com/KopiCloud-AD-API/terraform-provider-ad/api -p provider -o provider/kopicloud.resources-schemas.gen.go -i generator-inputs/computer.json -i generator-inputs/computer_cleanup.json -i generator-inputs/organizational_unit.json -i generator-inputs/dns_a_record.json -i generator-inputs/dns_aaaa_record.json -i generator-inputs/dns_cname_record.json -i generator-inputs/dns_lookup_zone.json -i generator-inputs/dns_reverse_lookup_zone.json -i generator-inputs/security_group.json -i generator-inputs/distribution_group.json -i generator-inputs/group_membership.json -i generator-inputs/user.json // Generate the code for the datasources (Schemas) //go:generate openapi-terraform-provider-generator datasource-schemas --api github.com/KopiCloud-AD-API/terraform-provider-ad/api -p provider -o provider/kopicloud.datasources-schemas.gen.go -i generator-inputs/computer.json -i generator-inputs/organizational_unit.json -i generator-inputs/dns_a_record.json -i generator-inputs/dns_aaaa_record.json -i generator-inputs/dns_cname_record.json -i generator-inputs/dns_lookup_zone.json -i generator-inputs/dns_reverse_lookup_zone.json -i generator-inputs/security_group.json -i generator-inputs/distribution_group.json -i generator-inputs/group_membership.json -i generator-inputs/user.json diff --git a/provider/kopicloud.computer-cleanup-crud.gen.go b/provider/kopicloud.computer-cleanup-crud.gen.go index 198aa9f..7791bf9 100644 --- a/provider/kopicloud.computer-cleanup-crud.gen.go +++ b/provider/kopicloud.computer-cleanup-crud.gen.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "reflect" kcapi "github.com/KopiCloud-AD-API/terraform-provider-ad/api" @@ -125,9 +126,17 @@ func resourceComputerCleanUpCreate(ctx context.Context, d *schema.ResourceData, api_result := res.JSON200.Result resItems := ComputerListToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted Computer: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted Computer }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted Computer", + map[string]interface{}{ + "Computer": resItems, + }) } result := resItems @@ -217,9 +226,17 @@ func resourceComputerCleanUpRead(ctx context.Context, d *schema.ResourceData, m api_result := res.JSON200.Result resItems := ComputerListToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted Computer: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted Computer }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted Computer", + map[string]interface{}{ + "Computer": resItems, + }) } result := resItems @@ -309,9 +326,17 @@ func resourceComputerCleanUpDelete(ctx context.Context, d *schema.ResourceData, api_result := res.JSON200.Result resItems := ComputerListToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted Computer: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted Computer }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted Computer", + map[string]interface{}{ + "Computer": resItems, + }) } result := resItems diff --git a/provider/kopicloud.computer-crud.gen.go b/provider/kopicloud.computer-crud.gen.go index 13f65d2..ec9d056 100644 --- a/provider/kopicloud.computer-crud.gen.go +++ b/provider/kopicloud.computer-crud.gen.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "reflect" kcapi "github.com/KopiCloud-AD-API/terraform-provider-ad/api" @@ -120,9 +121,17 @@ func resourceComputerCreate(ctx context.Context, d *schema.ResourceData, m inter api_result := res.JSON200.Result resItems := ComputerToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted Computer: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted Computer }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted Computer", + map[string]interface{}{ + "Computer": resItems, + }) } result := wrapInArray(resItems) @@ -198,9 +207,17 @@ func resourceComputerRead(ctx context.Context, d *schema.ResourceData, m interfa api_result := res.JSON200.Result resItems := ComputerToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted Computer: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted Computer }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted Computer", + map[string]interface{}{ + "Computer": resItems, + }) } result := wrapInArray(resItems) @@ -276,9 +293,17 @@ func resourceComputerDelete(ctx context.Context, d *schema.ResourceData, m inter api_result := res.JSON200.Result resItems := ComputerToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted Computer: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted Computer }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted Computer", + map[string]interface{}{ + "Computer": resItems, + }) } result := wrapInArray(resItems) diff --git a/provider/kopicloud.computer-data.gen.go b/provider/kopicloud.computer-data.gen.go index 6eb02a2..12143a5 100644 --- a/provider/kopicloud.computer-data.gen.go +++ b/provider/kopicloud.computer-data.gen.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "reflect" kcapi "github.com/KopiCloud-AD-API/terraform-provider-ad/api" @@ -122,10 +123,16 @@ func dataSourceComputer_Read_0(ctx context.Context, d *schema.ResourceData, m in resItems := ComputerToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted Computer }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted Computer", map[string]interface{}{ - "Computer": element, + "Computer": resItems, }) } @@ -202,10 +209,16 @@ func dataSourceComputer_Read_1(ctx context.Context, d *schema.ResourceData, m in resItems := ComputerListToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted Computer }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted Computer", map[string]interface{}{ - "Computer": element, + "Computer": resItems, }) } @@ -284,10 +297,16 @@ func dataSourceComputer_Read_2(ctx context.Context, d *schema.ResourceData, m in resItems := ComputerListToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted Computer }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted Computer", map[string]interface{}{ - "Computer": element, + "Computer": resItems, }) } diff --git a/provider/kopicloud.computer-update.gen.go b/provider/kopicloud.computer-update.gen.go index a5aec27..74c37b5 100644 --- a/provider/kopicloud.computer-update.gen.go +++ b/provider/kopicloud.computer-update.gen.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "reflect" kcapi "github.com/KopiCloud-AD-API/terraform-provider-ad/api" @@ -91,11 +92,16 @@ func resourceComputer_Update_0(ctx context.Context, d *schema.ResourceData, m in api_result := res.JSON200.Result resItems := ComputerToTerraform(api_result) - - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted Computer }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted Computer", map[string]interface{}{ - "Computer": element, + "Computer": resItems, }) } @@ -175,11 +181,16 @@ func resourceComputer_Update_1(ctx context.Context, d *schema.ResourceData, m in api_result := res.JSON200.Result resItems := ComputerToTerraform(api_result) - - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted Computer }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted Computer", map[string]interface{}{ - "Computer": element, + "Computer": resItems, }) } diff --git a/provider/kopicloud.converters.gen.go b/provider/kopicloud.converters.gen.go index 6e4430e..2e8011f 100644 --- a/provider/kopicloud.converters.gen.go +++ b/provider/kopicloud.converters.gen.go @@ -34,59 +34,59 @@ func isNotEmpty(f interface{}) bool { } } -func DnsRecordToTerraform(obj *api.DnsRecord) map[string]interface{} { +func OUToTerraform(obj *api.OU) map[string]interface{} { result := make(map[string]interface{}) - if obj.Type != nil && isNotEmpty(obj.Type) { + if obj.Guid != nil && isNotEmpty(obj.Guid) { - result["type"] = obj.Type + result["guid"] = UuidToTerraform(obj.Guid) } - if obj.Data != nil && isNotEmpty(obj.Data) { + if obj.Name != nil && isNotEmpty(obj.Name) { - result["data"] = obj.Data + result["name"] = obj.Name } - if obj.Zone != nil && isNotEmpty(obj.Zone) { + if obj.Description != nil && isNotEmpty(obj.Description) { - result["zone"] = obj.Zone + result["description"] = obj.Description } - if obj.Timestamp != nil && isNotEmpty(obj.Timestamp) { + if obj.Path != nil && isNotEmpty(obj.Path) { - result["timestamp"] = obj.Timestamp + result["path"] = obj.Path } - if obj.Name != nil && isNotEmpty(obj.Name) { + if obj.Protected != nil && isNotEmpty(obj.Protected) { - result["name"] = obj.Name + result["protected"] = obj.Protected } return result } -func DnsRecordListToTerraform(list *[]api.DnsRecord) []interface{} { +func OUListToTerraform(list *[]api.OU) []interface{} { if list != nil { results := make([]interface{}, len(*list)) - for i, DnsRecord := range *list { - results[i] = DnsRecordToTerraform(&DnsRecord) + for i, OU := range *list { + results[i] = OUToTerraform(&OU) } return results } return make([]interface{}, 0) } -func GroupToTerraform(obj *api.Group) map[string]interface{} { +func ComputerToTerraform(obj *api.Computer) map[string]interface{} { result := make(map[string]interface{}) - if obj.Scope != nil && isNotEmpty(obj.Scope) { + if obj.OperatingSystem != nil && isNotEmpty(obj.OperatingSystem) { - result["scope"] = obj.Scope + result["operating_system"] = obj.OperatingSystem } @@ -96,166 +96,199 @@ func GroupToTerraform(obj *api.Group) map[string]interface{} { } - if obj.Email != nil && isNotEmpty(obj.Email) { + if obj.DnsName != nil && isNotEmpty(obj.DnsName) { - result["email"] = obj.Email + result["dns_name"] = obj.DnsName } - if obj.OuPath != nil && isNotEmpty(obj.OuPath) { + if obj.Path != nil && isNotEmpty(obj.Path) { - result["ou_path"] = obj.OuPath + result["path"] = obj.Path } - if obj.Type != nil && isNotEmpty(obj.Type) { + if obj.Created != nil && isNotEmpty(obj.Created) { - result["type"] = obj.Type + result["created"] = obj.Created } - if obj.Guid != nil && isNotEmpty(obj.Guid) { + if obj.Sid != nil && isNotEmpty(obj.Sid) { - result["guid"] = UuidToTerraform(obj.Guid) + result["sid"] = obj.Sid } - if obj.Name != nil && isNotEmpty(obj.Name) { + if obj.ComputerName != nil && isNotEmpty(obj.ComputerName) { - result["name"] = obj.Name + result["computer_name"] = obj.ComputerName } return result } -func GroupListToTerraform(list *[]api.Group) []interface{} { +func ComputerListToTerraform(list *[]api.Computer) []interface{} { if list != nil { results := make([]interface{}, len(*list)) - for i, Group := range *list { - results[i] = GroupToTerraform(&Group) + for i, Computer := range *list { + results[i] = ComputerToTerraform(&Computer) } return results } return make([]interface{}, 0) } -func UserToTerraform(obj *api.User) map[string]interface{} { +func DnsRecordToTerraform(obj *api.DnsRecord) map[string]interface{} { result := make(map[string]interface{}) - if obj.LastName != nil && isNotEmpty(obj.LastName) { + if obj.Timestamp != nil && isNotEmpty(obj.Timestamp) { - result["last_name"] = obj.LastName + result["timestamp"] = obj.Timestamp } - if obj.DisplayName != nil && isNotEmpty(obj.DisplayName) { + if obj.Name != nil && isNotEmpty(obj.Name) { - result["display_name"] = obj.DisplayName + result["name"] = obj.Name } - if obj.Office != nil && isNotEmpty(obj.Office) { + if obj.Type != nil && isNotEmpty(obj.Type) { - result["office"] = obj.Office + result["type"] = obj.Type } - if obj.Manager != nil && isNotEmpty(obj.Manager) { + if obj.Data != nil && isNotEmpty(obj.Data) { - result["manager"] = obj.Manager + result["data"] = obj.Data } - if obj.PostalCode != nil && isNotEmpty(obj.PostalCode) { + if obj.Zone != nil && isNotEmpty(obj.Zone) { - result["postal_code"] = obj.PostalCode + result["zone"] = obj.Zone } - if obj.FirstName != nil && isNotEmpty(obj.FirstName) { - - result["first_name"] = obj.FirstName + return result +} +func DnsRecordListToTerraform(list *[]api.DnsRecord) []interface{} { + if list != nil { + results := make([]interface{}, len(*list)) + for i, DnsRecord := range *list { + results[i] = DnsRecordToTerraform(&DnsRecord) + } + return results } + return make([]interface{}, 0) +} - if obj.SamUsername != nil && isNotEmpty(obj.SamUsername) { +func DnsZoneToTerraform(obj *api.DnsZone) map[string]interface{} { + result := make(map[string]interface{}) - result["sam_username"] = obj.SamUsername + if obj.DistinguishedName != nil && isNotEmpty(obj.DistinguishedName) { + + result["distinguished_name"] = obj.DistinguishedName } - if obj.Initials != nil && isNotEmpty(obj.Initials) { + if obj.ZoneName != nil && isNotEmpty(obj.ZoneName) { - result["initials"] = obj.Initials + result["zone_name"] = obj.ZoneName } - if obj.Country != nil && isNotEmpty(obj.Country) { + if obj.ZoneType != nil && isNotEmpty(obj.ZoneType) { - result["country"] = obj.Country + result["zone_type"] = obj.ZoneType } - if obj.MobilePhone != nil && isNotEmpty(obj.MobilePhone) { + if obj.Type != nil && isNotEmpty(obj.Type) { - result["mobile_phone"] = obj.MobilePhone + result["type"] = obj.Type } - if obj.HomeFolderDrive != nil && isNotEmpty(obj.HomeFolderDrive) { - - result["home_folder_drive"] = obj.HomeFolderDrive + return result +} +func DnsZoneListToTerraform(list *[]api.DnsZone) []interface{} { + if list != nil { + results := make([]interface{}, len(*list)) + for i, DnsZone := range *list { + results[i] = DnsZoneToTerraform(&DnsZone) + } + return results } + return make([]interface{}, 0) +} - if obj.Username != nil && isNotEmpty(obj.Username) { +func GroupToTerraform(obj *api.Group) map[string]interface{} { + result := make(map[string]interface{}) - result["username"] = obj.Username + if obj.Type != nil && isNotEmpty(obj.Type) { + + result["type"] = obj.Type } - if obj.City != nil && isNotEmpty(obj.City) { + if obj.Guid != nil && isNotEmpty(obj.Guid) { - result["city"] = obj.City + result["guid"] = UuidToTerraform(obj.Guid) } - if obj.ProfilePath != nil && isNotEmpty(obj.ProfilePath) { + if obj.Name != nil && isNotEmpty(obj.Name) { - result["profile_path"] = obj.ProfilePath + result["name"] = obj.Name } - if obj.EmailAddress != nil && isNotEmpty(obj.EmailAddress) { + if obj.Scope != nil && isNotEmpty(obj.Scope) { - result["email_address"] = obj.EmailAddress + result["scope"] = obj.Scope } - if obj.State != nil && isNotEmpty(obj.State) { + if obj.Description != nil && isNotEmpty(obj.Description) { - result["state"] = obj.State + result["description"] = obj.Description } - if obj.OfficePhone != nil && isNotEmpty(obj.OfficePhone) { + if obj.Email != nil && isNotEmpty(obj.Email) { - result["office_phone"] = obj.OfficePhone + result["email"] = obj.Email } - if obj.HomeFolderPath != nil && isNotEmpty(obj.HomeFolderPath) { + if obj.OuPath != nil && isNotEmpty(obj.OuPath) { - result["home_folder_path"] = obj.HomeFolderPath + result["ou_path"] = obj.OuPath } - if obj.MiddleName != nil && isNotEmpty(obj.MiddleName) { - - result["middle_name"] = obj.MiddleName + return result +} +func GroupListToTerraform(list *[]api.Group) []interface{} { + if list != nil { + results := make([]interface{}, len(*list)) + for i, Group := range *list { + results[i] = GroupToTerraform(&Group) + } + return results } + return make([]interface{}, 0) +} + +func UserToTerraform(obj *api.User) map[string]interface{} { + result := make(map[string]interface{}) if obj.Company != nil && isNotEmpty(obj.Company) { @@ -263,33 +296,27 @@ func UserToTerraform(obj *api.User) map[string]interface{} { } - if obj.OuPath != nil && isNotEmpty(obj.OuPath) { - - result["ou_path"] = obj.OuPath - - } - - if obj.ChangePasswordNextLogon != nil && isNotEmpty(obj.ChangePasswordNextLogon) { + if obj.JobTitle != nil && isNotEmpty(obj.JobTitle) { - result["change_password_next_logon"] = obj.ChangePasswordNextLogon + result["job_title"] = obj.JobTitle } - if obj.JobTitle != nil && isNotEmpty(obj.JobTitle) { + if obj.Manager != nil && isNotEmpty(obj.Manager) { - result["job_title"] = obj.JobTitle + result["manager"] = obj.Manager } - if obj.ProfileLogonScript != nil && isNotEmpty(obj.ProfileLogonScript) { + if obj.StreetAddress != nil && isNotEmpty(obj.StreetAddress) { - result["profile_logon_script"] = obj.ProfileLogonScript + result["street_address"] = obj.StreetAddress } - if obj.RdsConnectDrive != nil && isNotEmpty(obj.RdsConnectDrive) { + if obj.OfficePhone != nil && isNotEmpty(obj.OfficePhone) { - result["rds_connect_drive"] = obj.RdsConnectDrive + result["office_phone"] = obj.OfficePhone } @@ -305,33 +332,39 @@ func UserToTerraform(obj *api.User) map[string]interface{} { } - if obj.StreetAddress != nil && isNotEmpty(obj.StreetAddress) { + if obj.Country != nil && isNotEmpty(obj.Country) { - result["street_address"] = obj.StreetAddress + result["country"] = obj.Country } - if obj.StreetPoBox != nil && isNotEmpty(obj.StreetPoBox) { + if obj.HomePhone != nil && isNotEmpty(obj.HomePhone) { - result["street_po_box"] = obj.StreetPoBox + result["home_phone"] = obj.HomePhone } - if obj.HomePhone != nil && isNotEmpty(obj.HomePhone) { + if obj.MobilePhone != nil && isNotEmpty(obj.MobilePhone) { - result["home_phone"] = obj.HomePhone + result["mobile_phone"] = obj.MobilePhone } - if obj.RdsHomeFolderPath != nil && isNotEmpty(obj.RdsHomeFolderPath) { + if obj.RdsProfilePath != nil && isNotEmpty(obj.RdsProfilePath) { - result["rds_home_folder_path"] = obj.RdsHomeFolderPath + result["rds_profile_path"] = obj.RdsProfilePath } - if obj.RdsHomeFolderDrive != nil && isNotEmpty(obj.RdsHomeFolderDrive) { + if obj.FirstName != nil && isNotEmpty(obj.FirstName) { - result["rds_home_folder_drive"] = obj.RdsHomeFolderDrive + result["first_name"] = obj.FirstName + + } + + if obj.ChangePasswordNextLogon != nil && isNotEmpty(obj.ChangePasswordNextLogon) { + + result["change_password_next_logon"] = obj.ChangePasswordNextLogon } @@ -341,173 +374,140 @@ func UserToTerraform(obj *api.User) map[string]interface{} { } - if obj.RdsProfilePath != nil && isNotEmpty(obj.RdsProfilePath) { + if obj.Office != nil && isNotEmpty(obj.Office) { - result["rds_profile_path"] = obj.RdsProfilePath + result["office"] = obj.Office } - if obj.RdsAllowLogon != nil && isNotEmpty(obj.RdsAllowLogon) { + if obj.City != nil && isNotEmpty(obj.City) { - result["rds_allow_logon"] = obj.RdsAllowLogon + result["city"] = obj.City } - return result -} + if obj.EmailAddress != nil && isNotEmpty(obj.EmailAddress) { -func UserListToTerraform(list *[]api.User) []interface{} { - if list != nil { - results := make([]interface{}, len(*list)) - for i, User := range *list { - results[i] = UserToTerraform(&User) - } - return results - } - return make([]interface{}, 0) -} + result["email_address"] = obj.EmailAddress -func DnsZoneToTerraform(obj *api.DnsZone) map[string]interface{} { - result := make(map[string]interface{}) + } - if obj.ZoneType != nil && isNotEmpty(obj.ZoneType) { + if obj.Username != nil && isNotEmpty(obj.Username) { - result["zone_type"] = obj.ZoneType + result["username"] = obj.Username } - if obj.Type != nil && isNotEmpty(obj.Type) { + if obj.LastName != nil && isNotEmpty(obj.LastName) { - result["type"] = obj.Type + result["last_name"] = obj.LastName } - if obj.DistinguishedName != nil && isNotEmpty(obj.DistinguishedName) { + if obj.RdsAllowLogon != nil && isNotEmpty(obj.RdsAllowLogon) { - result["distinguished_name"] = obj.DistinguishedName + result["rds_allow_logon"] = obj.RdsAllowLogon } - if obj.ZoneName != nil && isNotEmpty(obj.ZoneName) { + if obj.Initials != nil && isNotEmpty(obj.Initials) { - result["zone_name"] = obj.ZoneName + result["initials"] = obj.Initials } - return result -} + if obj.RdsConnectDrive != nil && isNotEmpty(obj.RdsConnectDrive) { -func DnsZoneListToTerraform(list *[]api.DnsZone) []interface{} { - if list != nil { - results := make([]interface{}, len(*list)) - for i, DnsZone := range *list { - results[i] = DnsZoneToTerraform(&DnsZone) - } - return results - } - return make([]interface{}, 0) -} + result["rds_connect_drive"] = obj.RdsConnectDrive -func OUToTerraform(obj *api.OU) map[string]interface{} { - result := make(map[string]interface{}) + } - if obj.Guid != nil && isNotEmpty(obj.Guid) { + if obj.State != nil && isNotEmpty(obj.State) { - result["guid"] = UuidToTerraform(obj.Guid) + result["state"] = obj.State } - if obj.Name != nil && isNotEmpty(obj.Name) { + if obj.ProfilePath != nil && isNotEmpty(obj.ProfilePath) { - result["name"] = obj.Name + result["profile_path"] = obj.ProfilePath } - if obj.Description != nil && isNotEmpty(obj.Description) { + if obj.MiddleName != nil && isNotEmpty(obj.MiddleName) { - result["description"] = obj.Description + result["middle_name"] = obj.MiddleName } - if obj.Path != nil && isNotEmpty(obj.Path) { + if obj.OuPath != nil && isNotEmpty(obj.OuPath) { - result["path"] = obj.Path + result["ou_path"] = obj.OuPath } - if obj.Protected != nil && isNotEmpty(obj.Protected) { + if obj.ProfileLogonScript != nil && isNotEmpty(obj.ProfileLogonScript) { - result["protected"] = obj.Protected + result["profile_logon_script"] = obj.ProfileLogonScript } - return result -} + if obj.HomeFolderDrive != nil && isNotEmpty(obj.HomeFolderDrive) { -func OUListToTerraform(list *[]api.OU) []interface{} { - if list != nil { - results := make([]interface{}, len(*list)) - for i, OU := range *list { - results[i] = OUToTerraform(&OU) - } - return results - } - return make([]interface{}, 0) -} + result["home_folder_drive"] = obj.HomeFolderDrive -func ComputerToTerraform(obj *api.Computer) map[string]interface{} { - result := make(map[string]interface{}) + } - if obj.Sid != nil && isNotEmpty(obj.Sid) { + if obj.DisplayName != nil && isNotEmpty(obj.DisplayName) { - result["sid"] = obj.Sid + result["display_name"] = obj.DisplayName } - if obj.ComputerName != nil && isNotEmpty(obj.ComputerName) { + if obj.PostalCode != nil && isNotEmpty(obj.PostalCode) { - result["computer_name"] = obj.ComputerName + result["postal_code"] = obj.PostalCode } - if obj.OperatingSystem != nil && isNotEmpty(obj.OperatingSystem) { + if obj.HomeFolderPath != nil && isNotEmpty(obj.HomeFolderPath) { - result["operating_system"] = obj.OperatingSystem + result["home_folder_path"] = obj.HomeFolderPath } - if obj.Description != nil && isNotEmpty(obj.Description) { + if obj.RdsHomeFolderPath != nil && isNotEmpty(obj.RdsHomeFolderPath) { - result["description"] = obj.Description + result["rds_home_folder_path"] = obj.RdsHomeFolderPath } - if obj.DnsName != nil && isNotEmpty(obj.DnsName) { + if obj.RdsHomeFolderDrive != nil && isNotEmpty(obj.RdsHomeFolderDrive) { - result["dns_name"] = obj.DnsName + result["rds_home_folder_drive"] = obj.RdsHomeFolderDrive } - if obj.Path != nil && isNotEmpty(obj.Path) { + if obj.SamUsername != nil && isNotEmpty(obj.SamUsername) { - result["path"] = obj.Path + result["sam_username"] = obj.SamUsername } - if obj.Created != nil && isNotEmpty(obj.Created) { + if obj.StreetPoBox != nil && isNotEmpty(obj.StreetPoBox) { - result["created"] = obj.Created + result["street_po_box"] = obj.StreetPoBox } return result } -func ComputerListToTerraform(list *[]api.Computer) []interface{} { +func UserListToTerraform(list *[]api.User) []interface{} { if list != nil { results := make([]interface{}, len(*list)) - for i, Computer := range *list { - results[i] = ComputerToTerraform(&Computer) + for i, User := range *list { + results[i] = UserToTerraform(&User) } return results } diff --git a/provider/kopicloud.distribution-group-crud.gen.go b/provider/kopicloud.distribution-group-crud.gen.go index 60e8849..eb20f85 100644 --- a/provider/kopicloud.distribution-group-crud.gen.go +++ b/provider/kopicloud.distribution-group-crud.gen.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "reflect" kcapi "github.com/KopiCloud-AD-API/terraform-provider-ad/api" @@ -146,9 +147,17 @@ func resourceDistributionGroupCreate(ctx context.Context, d *schema.ResourceData api_result := res.JSON200.Result resItems := GroupToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted Group: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted Group }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted Group", + map[string]interface{}{ + "Group": resItems, + }) } result := wrapInArray(resItems) @@ -224,9 +233,17 @@ func resourceDistributionGroupRead(ctx context.Context, d *schema.ResourceData, api_result := res.JSON200.Result resItems := GroupToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted Group: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted Group }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted Group", + map[string]interface{}{ + "Group": resItems, + }) } result := wrapInArray(resItems) @@ -306,9 +323,17 @@ func resourceDistributionGroupDelete(ctx context.Context, d *schema.ResourceData api_result := res.JSON200.Result resItems := GroupToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted Group: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted Group }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted Group", + map[string]interface{}{ + "Group": resItems, + }) } result := wrapInArray(resItems) diff --git a/provider/kopicloud.distribution-group-data.gen.go b/provider/kopicloud.distribution-group-data.gen.go index 58d43b0..dfc97f8 100644 --- a/provider/kopicloud.distribution-group-data.gen.go +++ b/provider/kopicloud.distribution-group-data.gen.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "reflect" kcapi "github.com/KopiCloud-AD-API/terraform-provider-ad/api" @@ -114,10 +115,16 @@ func dataSourceDistributioGroup_Read_0(ctx context.Context, d *schema.ResourceDa resItems := GroupToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DistributioGroup }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted DistributioGroup", map[string]interface{}{ - "DistributioGroup": element, + "DistributioGroup": resItems, }) } @@ -190,10 +197,16 @@ func dataSourceDistributioGroup_Read_1(ctx context.Context, d *schema.ResourceDa resItems := GroupListToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DistributioGroup }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted DistributioGroup", map[string]interface{}{ - "DistributioGroup": element, + "DistributioGroup": resItems, }) } diff --git a/provider/kopicloud.distribution-group-update.gen.go b/provider/kopicloud.distribution-group-update.gen.go index a5b5ca7..191211d 100644 --- a/provider/kopicloud.distribution-group-update.gen.go +++ b/provider/kopicloud.distribution-group-update.gen.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "reflect" kcapi "github.com/KopiCloud-AD-API/terraform-provider-ad/api" @@ -83,11 +84,16 @@ func resourceDistributionGroup_Update_0(ctx context.Context, d *schema.ResourceD api_result := res.JSON200.Result resItems := GroupToTerraform(api_result) - - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted Group }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted Group", map[string]interface{}{ - "Group": element, + "Group": resItems, }) } diff --git a/provider/kopicloud.dns_a_record-crud.gen.go b/provider/kopicloud.dns_a_record-crud.gen.go index 35c75d5..3f34918 100644 --- a/provider/kopicloud.dns_a_record-crud.gen.go +++ b/provider/kopicloud.dns_a_record-crud.gen.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "reflect" kcapi "github.com/KopiCloud-AD-API/terraform-provider-ad/api" @@ -124,9 +125,17 @@ func resourceDnsARecordCreate(ctx context.Context, d *schema.ResourceData, m int api_result := res.JSON200.Result resItems := DnsRecordToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted DnsARecord: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsARecord }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted DnsARecord", + map[string]interface{}{ + "DnsARecord": resItems, + }) } result := wrapInArray(resItems) @@ -210,9 +219,17 @@ func resourceDnsARecordRead(ctx context.Context, d *schema.ResourceData, m inter api_result := res.JSON200.Result resItems := DnsRecordToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted DnsARecord: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsARecord }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted DnsARecord", + map[string]interface{}{ + "DnsARecord": resItems, + }) } result := wrapInArray(resItems) @@ -296,9 +313,17 @@ func resourceDnsARecordDelete(ctx context.Context, d *schema.ResourceData, m int api_result := res.JSON200.Result resItems := DnsRecordToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted DnsARecord: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsARecord }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted DnsARecord", + map[string]interface{}{ + "DnsARecord": resItems, + }) } result := wrapInArray(resItems) diff --git a/provider/kopicloud.dns_a_record-data.gen.go b/provider/kopicloud.dns_a_record-data.gen.go index 87db4eb..eb5f10c 100644 --- a/provider/kopicloud.dns_a_record-data.gen.go +++ b/provider/kopicloud.dns_a_record-data.gen.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "reflect" kcapi "github.com/KopiCloud-AD-API/terraform-provider-ad/api" @@ -158,10 +159,16 @@ func dataSourceDnsARecordReader_Read_0(ctx context.Context, d *schema.ResourceDa resItems := DnsRecordToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsARecord }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted DnsARecord", map[string]interface{}{ - "DnsARecord": element, + "DnsARecord": resItems, }) } @@ -244,10 +251,16 @@ func dataSourceDnsARecordReader_Read_1(ctx context.Context, d *schema.ResourceDa resItems := DnsRecordListToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsARecord }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted DnsARecord", map[string]interface{}{ - "DnsARecord": element, + "DnsARecord": resItems, }) } @@ -330,10 +343,16 @@ func dataSourceDnsARecordReader_Read_2(ctx context.Context, d *schema.ResourceDa resItems := DnsRecordListToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsARecord }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted DnsARecord", map[string]interface{}{ - "DnsARecord": element, + "DnsARecord": resItems, }) } @@ -416,10 +435,16 @@ func dataSourceDnsARecordReader_Read_3(ctx context.Context, d *schema.ResourceDa resItems := DnsRecordListToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsARecord }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted DnsARecord", map[string]interface{}{ - "DnsARecord": element, + "DnsARecord": resItems, }) } @@ -498,10 +523,16 @@ func dataSourceDnsARecordReader_Read_4(ctx context.Context, d *schema.ResourceDa resItems := DnsRecordListToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsARecord }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted DnsARecord", map[string]interface{}{ - "DnsARecord": element, + "DnsARecord": resItems, }) } diff --git a/provider/kopicloud.dns_aaaa_record-crud.gen.go b/provider/kopicloud.dns_aaaa_record-crud.gen.go index 7902425..37c925c 100644 --- a/provider/kopicloud.dns_aaaa_record-crud.gen.go +++ b/provider/kopicloud.dns_aaaa_record-crud.gen.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "reflect" kcapi "github.com/KopiCloud-AD-API/terraform-provider-ad/api" @@ -124,9 +125,17 @@ func resourceDnsAAAARecordCreate(ctx context.Context, d *schema.ResourceData, m api_result := res.JSON200.Result resItems := DnsRecordToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted DnsAAAARecord: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsAAAARecord }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted DnsAAAARecord", + map[string]interface{}{ + "DnsAAAARecord": resItems, + }) } result := wrapInArray(resItems) @@ -210,9 +219,17 @@ func resourceDnsAAAARecordRead(ctx context.Context, d *schema.ResourceData, m in api_result := res.JSON200.Result resItems := DnsRecordToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted DnsAAAARecord: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsAAAARecord }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted DnsAAAARecord", + map[string]interface{}{ + "DnsAAAARecord": resItems, + }) } result := wrapInArray(resItems) @@ -296,9 +313,17 @@ func resourceDnsAAAARecordDelete(ctx context.Context, d *schema.ResourceData, m api_result := res.JSON200.Result resItems := DnsRecordToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted DnsAAAARecord: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsAAAARecord }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted DnsAAAARecord", + map[string]interface{}{ + "DnsAAAARecord": resItems, + }) } result := wrapInArray(resItems) diff --git a/provider/kopicloud.dns_aaaa_record-data.gen.go b/provider/kopicloud.dns_aaaa_record-data.gen.go index eb33de6..a37721d 100644 --- a/provider/kopicloud.dns_aaaa_record-data.gen.go +++ b/provider/kopicloud.dns_aaaa_record-data.gen.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "reflect" kcapi "github.com/KopiCloud-AD-API/terraform-provider-ad/api" @@ -158,10 +159,16 @@ func dataSourceDnsAAAARecordReader_Read_0(ctx context.Context, d *schema.Resourc resItems := DnsRecordToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsAAAARecord }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted DnsAAAARecord", map[string]interface{}{ - "DnsAAAARecord": element, + "DnsAAAARecord": resItems, }) } @@ -244,10 +251,16 @@ func dataSourceDnsAAAARecordReader_Read_1(ctx context.Context, d *schema.Resourc resItems := DnsRecordListToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsAAAARecord }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted DnsAAAARecord", map[string]interface{}{ - "DnsAAAARecord": element, + "DnsAAAARecord": resItems, }) } @@ -330,10 +343,16 @@ func dataSourceDnsAAAARecordReader_Read_2(ctx context.Context, d *schema.Resourc resItems := DnsRecordListToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsAAAARecord }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted DnsAAAARecord", map[string]interface{}{ - "DnsAAAARecord": element, + "DnsAAAARecord": resItems, }) } @@ -416,10 +435,16 @@ func dataSourceDnsAAAARecordReader_Read_3(ctx context.Context, d *schema.Resourc resItems := DnsRecordListToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsAAAARecord }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted DnsAAAARecord", map[string]interface{}{ - "DnsAAAARecord": element, + "DnsAAAARecord": resItems, }) } @@ -498,10 +523,16 @@ func dataSourceDnsAAAARecordReader_Read_4(ctx context.Context, d *schema.Resourc resItems := DnsRecordListToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsAAAARecord }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted DnsAAAARecord", map[string]interface{}{ - "DnsAAAARecord": element, + "DnsAAAARecord": resItems, }) } diff --git a/provider/kopicloud.dns_cname_record-crud.gen.go b/provider/kopicloud.dns_cname_record-crud.gen.go index c6ffef3..f534f9e 100644 --- a/provider/kopicloud.dns_cname_record-crud.gen.go +++ b/provider/kopicloud.dns_cname_record-crud.gen.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "reflect" kcapi "github.com/KopiCloud-AD-API/terraform-provider-ad/api" @@ -124,9 +125,17 @@ func resourceDnsCNameRecordCreate(ctx context.Context, d *schema.ResourceData, m api_result := res.JSON200.Result resItems := DnsRecordToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted DnsCNameRecord: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsCNameRecord }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted DnsCNameRecord", + map[string]interface{}{ + "DnsCNameRecord": resItems, + }) } result := wrapInArray(resItems) @@ -210,9 +219,17 @@ func resourceDnsCNameRecordRead(ctx context.Context, d *schema.ResourceData, m i api_result := res.JSON200.Result resItems := DnsRecordToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted DnsCNameRecord: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsCNameRecord }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted DnsCNameRecord", + map[string]interface{}{ + "DnsCNameRecord": resItems, + }) } result := wrapInArray(resItems) @@ -296,9 +313,17 @@ func resourceDnsCNameRecordDelete(ctx context.Context, d *schema.ResourceData, m api_result := res.JSON200.Result resItems := DnsRecordToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted DnsCNameRecord: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsCNameRecord }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted DnsCNameRecord", + map[string]interface{}{ + "DnsCNameRecord": resItems, + }) } result := wrapInArray(resItems) diff --git a/provider/kopicloud.dns_cname_record-data.gen.go b/provider/kopicloud.dns_cname_record-data.gen.go index 32adf7d..2856e28 100644 --- a/provider/kopicloud.dns_cname_record-data.gen.go +++ b/provider/kopicloud.dns_cname_record-data.gen.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "reflect" kcapi "github.com/KopiCloud-AD-API/terraform-provider-ad/api" @@ -158,10 +159,16 @@ func dataSourceDnsCNameRecordReader_Read_0(ctx context.Context, d *schema.Resour resItems := DnsRecordToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsCNameRecord }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted DnsCNameRecord", map[string]interface{}{ - "DnsCNameRecord": element, + "DnsCNameRecord": resItems, }) } @@ -244,10 +251,16 @@ func dataSourceDnsCNameRecordReader_Read_1(ctx context.Context, d *schema.Resour resItems := DnsRecordListToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsCNameRecord }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted DnsCNameRecord", map[string]interface{}{ - "DnsCNameRecord": element, + "DnsCNameRecord": resItems, }) } @@ -330,10 +343,16 @@ func dataSourceDnsCNameRecordReader_Read_2(ctx context.Context, d *schema.Resour resItems := DnsRecordListToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsCNameRecord }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted DnsCNameRecord", map[string]interface{}{ - "DnsCNameRecord": element, + "DnsCNameRecord": resItems, }) } @@ -416,10 +435,16 @@ func dataSourceDnsCNameRecordReader_Read_3(ctx context.Context, d *schema.Resour resItems := DnsRecordListToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsCNameRecord }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted DnsCNameRecord", map[string]interface{}{ - "DnsCNameRecord": element, + "DnsCNameRecord": resItems, }) } @@ -498,10 +523,16 @@ func dataSourceDnsCNameRecordReader_Read_4(ctx context.Context, d *schema.Resour resItems := DnsRecordListToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsCNameRecord }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted DnsCNameRecord", map[string]interface{}{ - "DnsCNameRecord": element, + "DnsCNameRecord": resItems, }) } diff --git a/provider/kopicloud.dns_lookup_zone-crud.gen.go b/provider/kopicloud.dns_lookup_zone-crud.gen.go index 7a11111..4144acf 100644 --- a/provider/kopicloud.dns_lookup_zone-crud.gen.go +++ b/provider/kopicloud.dns_lookup_zone-crud.gen.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "reflect" kcapi "github.com/KopiCloud-AD-API/terraform-provider-ad/api" @@ -94,9 +95,17 @@ func resourceDnsLookupZoneCreate(ctx context.Context, d *schema.ResourceData, m api_result := res.JSON200.Result resItems := DnsZoneToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted DnsLookupZone: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsLookupZone }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted DnsLookupZone", + map[string]interface{}{ + "DnsLookupZone": resItems, + }) } result := wrapInArray(resItems) @@ -172,9 +181,17 @@ func resourceDnsLookupZoneRead(ctx context.Context, d *schema.ResourceData, m in api_result := res.JSON200.Result resItems := DnsZoneToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted DnsLookupZone: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsLookupZone }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted DnsLookupZone", + map[string]interface{}{ + "DnsLookupZone": resItems, + }) } result := wrapInArray(resItems) @@ -250,9 +267,17 @@ func resourceDnsLookupZoneDelete(ctx context.Context, d *schema.ResourceData, m api_result := res.JSON200.Result resItems := DnsZoneToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted DnsLookupZone: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsLookupZone }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted DnsLookupZone", + map[string]interface{}{ + "DnsLookupZone": resItems, + }) } result := wrapInArray(resItems) diff --git a/provider/kopicloud.dns_lookup_zone-data.gen.go b/provider/kopicloud.dns_lookup_zone-data.gen.go index ee8806d..37617c3 100644 --- a/provider/kopicloud.dns_lookup_zone-data.gen.go +++ b/provider/kopicloud.dns_lookup_zone-data.gen.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "reflect" kcapi "github.com/KopiCloud-AD-API/terraform-provider-ad/api" @@ -86,10 +87,16 @@ func dataSourceDnsZoneReader_Read_0(ctx context.Context, d *schema.ResourceData, resItems := DnsZoneListToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsZone }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted DnsZone", map[string]interface{}{ - "DnsZone": element, + "DnsZone": resItems, }) } @@ -212,10 +219,16 @@ func dataSourceDnsLookupZoneReader_Read_0(ctx context.Context, d *schema.Resourc resItems := DnsZoneToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsLookupZone }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted DnsLookupZone", map[string]interface{}{ - "DnsLookupZone": element, + "DnsLookupZone": resItems, }) } @@ -294,10 +307,16 @@ func dataSourceDnsLookupZoneReader_Read_1(ctx context.Context, d *schema.Resourc resItems := DnsZoneListToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsLookupZone }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted DnsLookupZone", map[string]interface{}{ - "DnsLookupZone": element, + "DnsLookupZone": resItems, }) } diff --git a/provider/kopicloud.dns_reverse_lookup_zone-crud.gen.go b/provider/kopicloud.dns_reverse_lookup_zone-crud.gen.go index 7ee6baa..f524c28 100644 --- a/provider/kopicloud.dns_reverse_lookup_zone-crud.gen.go +++ b/provider/kopicloud.dns_reverse_lookup_zone-crud.gen.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "reflect" kcapi "github.com/KopiCloud-AD-API/terraform-provider-ad/api" @@ -94,9 +95,17 @@ func resourceDnsReverseLookupZoneCreate(ctx context.Context, d *schema.ResourceD api_result := res.JSON200.Result resItems := DnsZoneToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted DnsReverseLookupZone: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsReverseLookupZone }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted DnsReverseLookupZone", + map[string]interface{}{ + "DnsReverseLookupZone": resItems, + }) } result := wrapInArray(resItems) @@ -172,9 +181,17 @@ func resourceDnsReverseLookupZoneRead(ctx context.Context, d *schema.ResourceDat api_result := res.JSON200.Result resItems := DnsZoneToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted DnsReverseLookupZone: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsReverseLookupZone }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted DnsReverseLookupZone", + map[string]interface{}{ + "DnsReverseLookupZone": resItems, + }) } result := wrapInArray(resItems) @@ -250,9 +267,17 @@ func resourceDnsReverseLookupZoneDelete(ctx context.Context, d *schema.ResourceD api_result := res.JSON200.Result resItems := DnsZoneToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted DnsReverseLookupZone: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsReverseLookupZone }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted DnsReverseLookupZone", + map[string]interface{}{ + "DnsReverseLookupZone": resItems, + }) } result := wrapInArray(resItems) diff --git a/provider/kopicloud.dns_reverse_lookup_zone-data.gen.go b/provider/kopicloud.dns_reverse_lookup_zone-data.gen.go index 96f70c7..10c0092 100644 --- a/provider/kopicloud.dns_reverse_lookup_zone-data.gen.go +++ b/provider/kopicloud.dns_reverse_lookup_zone-data.gen.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "reflect" kcapi "github.com/KopiCloud-AD-API/terraform-provider-ad/api" @@ -106,10 +107,16 @@ func dataSourceDnsReverseLookupZoneReader_Read_0(ctx context.Context, d *schema. resItems := DnsZoneToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsLookupZone }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted DnsLookupZone", map[string]interface{}{ - "DnsLookupZone": element, + "DnsLookupZone": resItems, }) } @@ -182,10 +189,16 @@ func dataSourceDnsReverseLookupZoneReader_Read_1(ctx context.Context, d *schema. resItems := DnsZoneListToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted DnsLookupZone }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted DnsLookupZone", map[string]interface{}{ - "DnsLookupZone": element, + "DnsLookupZone": resItems, }) } diff --git a/provider/kopicloud.group-memberships-crud.gen.go b/provider/kopicloud.group-memberships-crud.gen.go index 91cc393..be0f60b 100644 --- a/provider/kopicloud.group-memberships-crud.gen.go +++ b/provider/kopicloud.group-memberships-crud.gen.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "reflect" kcapi "github.com/KopiCloud-AD-API/terraform-provider-ad/api" @@ -109,9 +110,17 @@ func resourceGroupMembershipCreate(ctx context.Context, d *schema.ResourceData, api_result := res.JSON200.Result resItems := GroupToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted Group: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted Group }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted Group", + map[string]interface{}{ + "Group": resItems, + }) } result := wrapInArray(resItems) @@ -191,9 +200,17 @@ func resourceGroupMembershipRead(ctx context.Context, d *schema.ResourceData, m api_result := res.JSON200.Result resItems := GroupToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted Group: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted Group }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted Group", + map[string]interface{}{ + "Group": resItems, + }) } result := wrapInArray(resItems) @@ -273,9 +290,17 @@ func resourceGroupMembershipDelete(ctx context.Context, d *schema.ResourceData, api_result := res.JSON200.Result resItems := GroupToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted Group: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted Group }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted Group", + map[string]interface{}{ + "Group": resItems, + }) } result := wrapInArray(resItems) diff --git a/provider/kopicloud.group-memberships-data.gen.go b/provider/kopicloud.group-memberships-data.gen.go index e06726d..5509241 100644 --- a/provider/kopicloud.group-memberships-data.gen.go +++ b/provider/kopicloud.group-memberships-data.gen.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "reflect" kcapi "github.com/KopiCloud-AD-API/terraform-provider-ad/api" @@ -118,10 +119,16 @@ func dataSourceGroupMembership_Read_0(ctx context.Context, d *schema.ResourceDat resItems := GroupListToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted GroupMembership }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted GroupMembership", map[string]interface{}{ - "GroupMembership": element, + "GroupMembership": resItems, }) } @@ -208,10 +215,16 @@ func dataSourceGroupMembership_Read_1(ctx context.Context, d *schema.ResourceDat resItems := GroupToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted GroupMembership }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted GroupMembership", map[string]interface{}{ - "GroupMembership": element, + "GroupMembership": resItems, }) } diff --git a/provider/kopicloud.ou-crud.gen.go b/provider/kopicloud.ou-crud.gen.go index c09c638..36d598f 100644 --- a/provider/kopicloud.ou-crud.gen.go +++ b/provider/kopicloud.ou-crud.gen.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "reflect" kcapi "github.com/KopiCloud-AD-API/terraform-provider-ad/api" @@ -134,9 +135,17 @@ func resourceOUCreate(ctx context.Context, d *schema.ResourceData, m interface{} api_result := res.JSON200.Result resItems := OUToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted OU: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted OU }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted OU", + map[string]interface{}{ + "OU": resItems, + }) } result := wrapInArray(resItems) @@ -215,9 +224,17 @@ func resourceOURead(ctx context.Context, d *schema.ResourceData, m interface{}) api_result := res.JSON200.Result resItems := OUToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted OU: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted OU }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted OU", + map[string]interface{}{ + "OU": resItems, + }) } result := wrapInArray(resItems) @@ -297,9 +314,17 @@ func resourceOUDelete(ctx context.Context, d *schema.ResourceData, m interface{} api_result := res.JSON200.Result resItems := OUToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted OU: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted OU }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted OU", + map[string]interface{}{ + "OU": resItems, + }) } result := wrapInArray(resItems) diff --git a/provider/kopicloud.ou-data.gen.go b/provider/kopicloud.ou-data.gen.go index 4a8458b..f79e6cb 100644 --- a/provider/kopicloud.ou-data.gen.go +++ b/provider/kopicloud.ou-data.gen.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "reflect" kcapi "github.com/KopiCloud-AD-API/terraform-provider-ad/api" @@ -114,10 +115,16 @@ func dataSourceOU_Read_0(ctx context.Context, d *schema.ResourceData, m interfac resItems := OUToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted OU }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted OU", map[string]interface{}{ - "OU": element, + "OU": resItems, }) } @@ -190,10 +197,16 @@ func dataSourceOU_Read_1(ctx context.Context, d *schema.ResourceData, m interfac resItems := OUListToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted OU }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted OU", map[string]interface{}{ - "OU": element, + "OU": resItems, }) } diff --git a/provider/kopicloud.ou-update.gen.go b/provider/kopicloud.ou-update.gen.go index 5bbe026..2e0e2d3 100644 --- a/provider/kopicloud.ou-update.gen.go +++ b/provider/kopicloud.ou-update.gen.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "reflect" kcapi "github.com/KopiCloud-AD-API/terraform-provider-ad/api" @@ -91,11 +92,16 @@ func resourceOU_Update_0(ctx context.Context, d *schema.ResourceData, m interfac api_result := res.JSON200.Result resItems := OUToTerraform(api_result) - - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted OU }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted OU", map[string]interface{}{ - "OU": element, + "OU": resItems, }) } @@ -179,11 +185,16 @@ func resourceOU_Update_1(ctx context.Context, d *schema.ResourceData, m interfac api_result := res.JSON200.Result resItems := OUToTerraform(api_result) - - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted OU }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted OU", map[string]interface{}{ - "OU": element, + "OU": resItems, }) } diff --git a/provider/kopicloud.resources-schemas.gen.go b/provider/kopicloud.resources-schemas.gen.go index 84eacc3..bc81e4d 100644 --- a/provider/kopicloud.resources-schemas.gen.go +++ b/provider/kopicloud.resources-schemas.gen.go @@ -43,7 +43,5 @@ func resources() map[string]*schema.Resource { "kopicloud_group_membership": resourceGroupMembership(), "kopicloud_user": resourceUser(), - - "kopicloud_user_password_reset": resourceUserPasswordReset(), } } diff --git a/provider/kopicloud.schemas.gen.go b/provider/kopicloud.schemas.gen.go index 302767d..d647338 100644 --- a/provider/kopicloud.schemas.gen.go +++ b/provider/kopicloud.schemas.gen.go @@ -37,56 +37,56 @@ func schemaMapOfScalarElement(t schema.ValueType, field_name string) map[string] } } -func schemaOfDnsRecordList(scalar_field_name string) *schema.Schema { +func schemaOfOUList(scalar_field_name string) *schema.Schema { return &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: fmt.Sprintf("List of %s", "DnsRecord"), + Description: fmt.Sprintf("List of %s", "OU"), Elem: &schema.Resource{ - Schema: schemaMapOfDnsRecord(scalar_field_name), + Schema: schemaMapOfOU(scalar_field_name), }, } } -func schemaOfDnsRecord(scalar_field_name string) *schema.Schema { +func schemaOfOU(scalar_field_name string) *schema.Schema { return &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: fmt.Sprintf("Single Element List of %s", "DnsRecord"), + Description: fmt.Sprintf("Single Element List of %s", "OU"), Elem: &schema.Resource{ - Schema: schemaMapOfDnsRecord(scalar_field_name), + Schema: schemaMapOfOU(scalar_field_name), }, } } -func schemaMapOfDnsRecord(scalar_field_name string) map[string]*schema.Schema { +func schemaMapOfOU(scalar_field_name string) map[string]*schema.Schema { return map[string]*schema.Schema{ - "name": { + "path": { Type: schema.TypeString, Computed: true, Description: "", }, - "type": { - Type: schema.TypeString, + "protected": { + Type: schema.TypeBool, Computed: true, Description: "", }, - "data": { + "guid": { Type: schema.TypeString, Computed: true, Description: "", }, - "zone": { + "name": { Type: schema.TypeString, Computed: true, Description: "", }, - "timestamp": { + "description": { Type: schema.TypeString, Computed: true, Description: "", @@ -94,482 +94,482 @@ func schemaMapOfDnsRecord(scalar_field_name string) map[string]*schema.Schema { } } -func schemaOfGroupList(scalar_field_name string) *schema.Schema { +func schemaOfUserList(scalar_field_name string) *schema.Schema { return &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: fmt.Sprintf("List of %s", "Group"), + Description: fmt.Sprintf("List of %s", "User"), Elem: &schema.Resource{ - Schema: schemaMapOfGroup(scalar_field_name), + Schema: schemaMapOfUser(scalar_field_name), }, } } -func schemaOfGroup(scalar_field_name string) *schema.Schema { +func schemaOfUser(scalar_field_name string) *schema.Schema { return &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: fmt.Sprintf("Single Element List of %s", "Group"), + Description: fmt.Sprintf("Single Element List of %s", "User"), Elem: &schema.Resource{ - Schema: schemaMapOfGroup(scalar_field_name), + Schema: schemaMapOfUser(scalar_field_name), }, } } -func schemaMapOfGroup(scalar_field_name string) map[string]*schema.Schema { +func schemaMapOfUser(scalar_field_name string) map[string]*schema.Schema { return map[string]*schema.Schema{ - "ou_path": { + "street_po_box": { Type: schema.TypeString, Computed: true, Description: "", }, - "type": { + "postal_code": { Type: schema.TypeString, Computed: true, Description: "", }, - "guid": { + "country": { Type: schema.TypeString, Computed: true, Description: "", }, - "name": { + "office_phone": { Type: schema.TypeString, Computed: true, Description: "", }, - "scope": { + "home_phone": { Type: schema.TypeString, Computed: true, Description: "", }, - "description": { + "middle_name": { Type: schema.TypeString, Computed: true, Description: "", }, - "email": { + "display_name": { Type: schema.TypeString, Computed: true, Description: "", }, - } -} - -func schemaOfComputerList(scalar_field_name string) *schema.Schema { - return &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: fmt.Sprintf("List of %s", "Computer"), - Elem: &schema.Resource{ - Schema: schemaMapOfComputer(scalar_field_name), - }, - } -} - -func schemaOfComputer(scalar_field_name string) *schema.Schema { - return &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: fmt.Sprintf("Single Element List of %s", "Computer"), - Elem: &schema.Resource{ - Schema: schemaMapOfComputer(scalar_field_name), - }, - } -} - -func schemaMapOfComputer(scalar_field_name string) map[string]*schema.Schema { - return map[string]*schema.Schema{ - "created": { + "description": { Type: schema.TypeString, Computed: true, Description: "", }, - "sid": { + "home_folder_path": { Type: schema.TypeString, Computed: true, Description: "", }, - "computer_name": { - Type: schema.TypeString, + "rds_allow_logon": { + Type: schema.TypeBool, Computed: true, Description: "", }, - "operating_system": { + "initials": { Type: schema.TypeString, Computed: true, Description: "", }, - "description": { + "ou_path": { Type: schema.TypeString, Computed: true, Description: "", }, - "dns_name": { + "rds_home_folder_path": { Type: schema.TypeString, Computed: true, Description: "", }, - "path": { + "first_name": { Type: schema.TypeString, Computed: true, Description: "", }, - } -} - -func schemaOfDnsZoneList(scalar_field_name string) *schema.Schema { - return &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: fmt.Sprintf("List of %s", "DnsZone"), - Elem: &schema.Resource{ - Schema: schemaMapOfDnsZone(scalar_field_name), - }, - } -} - -func schemaOfDnsZone(scalar_field_name string) *schema.Schema { - return &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: fmt.Sprintf("Single Element List of %s", "DnsZone"), - Elem: &schema.Resource{ - Schema: schemaMapOfDnsZone(scalar_field_name), - }, - } -} -func schemaMapOfDnsZone(scalar_field_name string) map[string]*schema.Schema { - return map[string]*schema.Schema{ - - "distinguished_name": { + "last_name": { Type: schema.TypeString, Computed: true, Description: "", }, - "zone_name": { + "office": { Type: schema.TypeString, Computed: true, Description: "", }, - "zone_type": { + "department": { Type: schema.TypeString, Computed: true, Description: "", }, - "type": { + "city": { Type: schema.TypeString, Computed: true, Description: "", }, - } -} - -func schemaOfOUList(scalar_field_name string) *schema.Schema { - return &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: fmt.Sprintf("List of %s", "OU"), - Elem: &schema.Resource{ - Schema: schemaMapOfOU(scalar_field_name), - }, - } -} - -func schemaOfOU(scalar_field_name string) *schema.Schema { - return &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: fmt.Sprintf("Single Element List of %s", "OU"), - Elem: &schema.Resource{ - Schema: schemaMapOfOU(scalar_field_name), - }, - } -} - -func schemaMapOfOU(scalar_field_name string) map[string]*schema.Schema { - return map[string]*schema.Schema{ - "name": { + "home_folder_directory": { Type: schema.TypeString, Computed: true, Description: "", }, - "description": { + "rds_home_folder_drive": { Type: schema.TypeString, Computed: true, Description: "", }, - "path": { + "username": { Type: schema.TypeString, Computed: true, Description: "", }, - "protected": { - Type: schema.TypeBool, + "company": { + Type: schema.TypeString, Computed: true, Description: "", }, - "guid": { + "mobile_phone": { Type: schema.TypeString, Computed: true, Description: "", }, - } -} - -func schemaOfUserList(scalar_field_name string) *schema.Schema { - return &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: fmt.Sprintf("List of %s", "User"), - Elem: &schema.Resource{ - Schema: schemaMapOfUser(scalar_field_name), - }, - } -} - -func schemaOfUser(scalar_field_name string) *schema.Schema { - return &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: fmt.Sprintf("Single Element List of %s", "User"), - Elem: &schema.Resource{ - Schema: schemaMapOfUser(scalar_field_name), - }, - } -} -func schemaMapOfUser(scalar_field_name string) map[string]*schema.Schema { - return map[string]*schema.Schema{ - - "profile_path": { + "rds_profile_path": { Type: schema.TypeString, Computed: true, Description: "", }, - "home_folder_directory": { - Type: schema.TypeString, + "change_password_next_logon": { + Type: schema.TypeBool, Computed: true, Description: "", }, - "last_name": { + "manager": { Type: schema.TypeString, Computed: true, Description: "", }, - "job_title": { + "profile_logon_script": { Type: schema.TypeString, Computed: true, Description: "", }, - "mobile_phone": { + "email_address": { Type: schema.TypeString, Computed: true, Description: "", }, - "manager": { + "street_address": { Type: schema.TypeString, Computed: true, Description: "", }, - "state": { + "sam_username": { Type: schema.TypeString, Computed: true, Description: "", }, - "middle_name": { - Type: schema.TypeString, + "rds_connect_drive": { + Type: schema.TypeBool, Computed: true, Description: "", }, - "email_address": { + "home_folder_drive": { Type: schema.TypeString, Computed: true, Description: "", }, - "office": { + "job_title": { Type: schema.TypeString, Computed: true, Description: "", }, - "first_name": { + "state": { Type: schema.TypeString, Computed: true, Description: "", }, - "display_name": { + "profile_path": { Type: schema.TypeString, Computed: true, Description: "", }, + } +} - "country": { +func schemaOfComputerList(scalar_field_name string) *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: fmt.Sprintf("List of %s", "Computer"), + Elem: &schema.Resource{ + Schema: schemaMapOfComputer(scalar_field_name), + }, + } +} + +func schemaOfComputer(scalar_field_name string) *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: fmt.Sprintf("Single Element List of %s", "Computer"), + Elem: &schema.Resource{ + Schema: schemaMapOfComputer(scalar_field_name), + }, + } +} + +func schemaMapOfComputer(scalar_field_name string) map[string]*schema.Schema { + return map[string]*schema.Schema{ + + "operating_system": { Type: schema.TypeString, Computed: true, Description: "", }, - "department": { + "description": { Type: schema.TypeString, Computed: true, Description: "", }, - "office_phone": { + "dns_name": { Type: schema.TypeString, Computed: true, Description: "", }, - "home_folder_drive": { + "path": { Type: schema.TypeString, Computed: true, Description: "", }, - "street_address": { + "created": { Type: schema.TypeString, Computed: true, Description: "", }, - "postal_code": { + "sid": { Type: schema.TypeString, Computed: true, Description: "", }, - "rds_home_folder_path": { + "computer_name": { Type: schema.TypeString, Computed: true, Description: "", }, + } +} - "description": { +func schemaOfDnsRecordList(scalar_field_name string) *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: fmt.Sprintf("List of %s", "DnsRecord"), + Elem: &schema.Resource{ + Schema: schemaMapOfDnsRecord(scalar_field_name), + }, + } +} + +func schemaOfDnsRecord(scalar_field_name string) *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: fmt.Sprintf("Single Element List of %s", "DnsRecord"), + Elem: &schema.Resource{ + Schema: schemaMapOfDnsRecord(scalar_field_name), + }, + } +} + +func schemaMapOfDnsRecord(scalar_field_name string) map[string]*schema.Schema { + return map[string]*schema.Schema{ + + "name": { Type: schema.TypeString, Computed: true, Description: "", }, - "sam_username": { + "type": { Type: schema.TypeString, Computed: true, Description: "", }, - "ou_path": { + "data": { Type: schema.TypeString, Computed: true, Description: "", }, - "initials": { + "zone": { Type: schema.TypeString, Computed: true, Description: "", }, - "home_phone": { + "timestamp": { Type: schema.TypeString, Computed: true, Description: "", }, + } +} - "street_po_box": { +func schemaOfDnsZoneList(scalar_field_name string) *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: fmt.Sprintf("List of %s", "DnsZone"), + Elem: &schema.Resource{ + Schema: schemaMapOfDnsZone(scalar_field_name), + }, + } +} + +func schemaOfDnsZone(scalar_field_name string) *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: fmt.Sprintf("Single Element List of %s", "DnsZone"), + Elem: &schema.Resource{ + Schema: schemaMapOfDnsZone(scalar_field_name), + }, + } +} + +func schemaMapOfDnsZone(scalar_field_name string) map[string]*schema.Schema { + return map[string]*schema.Schema{ + + "distinguished_name": { Type: schema.TypeString, Computed: true, Description: "", }, - "profile_logon_script": { + "zone_name": { Type: schema.TypeString, Computed: true, Description: "", }, - "rds_profile_path": { + "zone_type": { Type: schema.TypeString, Computed: true, Description: "", }, - "username": { + "type": { Type: schema.TypeString, Computed: true, Description: "", }, + } +} - "company": { +func schemaOfGroupList(scalar_field_name string) *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: fmt.Sprintf("List of %s", "Group"), + Elem: &schema.Resource{ + Schema: schemaMapOfGroup(scalar_field_name), + }, + } +} + +func schemaOfGroup(scalar_field_name string) *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: fmt.Sprintf("Single Element List of %s", "Group"), + Elem: &schema.Resource{ + Schema: schemaMapOfGroup(scalar_field_name), + }, + } +} + +func schemaMapOfGroup(scalar_field_name string) map[string]*schema.Schema { + return map[string]*schema.Schema{ + + "guid": { Type: schema.TypeString, Computed: true, Description: "", }, - "change_password_next_logon": { - Type: schema.TypeBool, + "name": { + Type: schema.TypeString, Computed: true, Description: "", }, - "rds_connect_drive": { - Type: schema.TypeBool, + "scope": { + Type: schema.TypeString, Computed: true, Description: "", }, - "rds_allow_logon": { - Type: schema.TypeBool, + "description": { + Type: schema.TypeString, Computed: true, Description: "", }, - "city": { + "email": { Type: schema.TypeString, Computed: true, Description: "", }, - "home_folder_path": { + "ou_path": { Type: schema.TypeString, Computed: true, Description: "", }, - "rds_home_folder_drive": { + "type": { Type: schema.TypeString, Computed: true, Description: "", diff --git a/provider/kopicloud.security-group-crud.gen.go b/provider/kopicloud.security-group-crud.gen.go index ce94853..43a4a27 100644 --- a/provider/kopicloud.security-group-crud.gen.go +++ b/provider/kopicloud.security-group-crud.gen.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "reflect" kcapi "github.com/KopiCloud-AD-API/terraform-provider-ad/api" @@ -146,9 +147,17 @@ func resourceGroupCreate(ctx context.Context, d *schema.ResourceData, m interfac api_result := res.JSON200.Result resItems := GroupToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted Group: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted Group }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted Group", + map[string]interface{}{ + "Group": resItems, + }) } result := wrapInArray(resItems) @@ -224,9 +233,17 @@ func resourceGroupRead(ctx context.Context, d *schema.ResourceData, m interface{ api_result := res.JSON200.Result resItems := GroupToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted Group: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted Group }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted Group", + map[string]interface{}{ + "Group": resItems, + }) } result := wrapInArray(resItems) @@ -306,9 +323,17 @@ func resourceGroupDelete(ctx context.Context, d *schema.ResourceData, m interfac api_result := res.JSON200.Result resItems := GroupToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted Group: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted Group }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted Group", + map[string]interface{}{ + "Group": resItems, + }) } result := wrapInArray(resItems) diff --git a/provider/kopicloud.security-group-data.gen.go b/provider/kopicloud.security-group-data.gen.go index 8a1b54f..af740d9 100644 --- a/provider/kopicloud.security-group-data.gen.go +++ b/provider/kopicloud.security-group-data.gen.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "reflect" kcapi "github.com/KopiCloud-AD-API/terraform-provider-ad/api" @@ -86,10 +87,16 @@ func dataSourceGroup_Read_0(ctx context.Context, d *schema.ResourceData, m inter resItems := GroupListToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted Group }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted Group", map[string]interface{}{ - "Group": element, + "Group": resItems, }) } @@ -220,10 +227,16 @@ func dataSourceSecurityGroup_Read_0(ctx context.Context, d *schema.ResourceData, resItems := GroupToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted SecurityGroup }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted SecurityGroup", map[string]interface{}{ - "SecurityGroup": element, + "SecurityGroup": resItems, }) } @@ -296,10 +309,16 @@ func dataSourceSecurityGroup_Read_1(ctx context.Context, d *schema.ResourceData, resItems := GroupListToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted SecurityGroup }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted SecurityGroup", map[string]interface{}{ - "SecurityGroup": element, + "SecurityGroup": resItems, }) } diff --git a/provider/kopicloud.security-group-update.gen.go b/provider/kopicloud.security-group-update.gen.go index 21aad58..7c6adf3 100644 --- a/provider/kopicloud.security-group-update.gen.go +++ b/provider/kopicloud.security-group-update.gen.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "reflect" kcapi "github.com/KopiCloud-AD-API/terraform-provider-ad/api" @@ -83,11 +84,16 @@ func resourceGroup_Update_0(ctx context.Context, d *schema.ResourceData, m inter api_result := res.JSON200.Result resItems := GroupToTerraform(api_result) - - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted Group }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted Group", map[string]interface{}{ - "Group": element, + "Group": resItems, }) } diff --git a/provider/kopicloud.user-crud.gen.go b/provider/kopicloud.user-crud.gen.go index 8b8bd53..ad76377 100644 --- a/provider/kopicloud.user-crud.gen.go +++ b/provider/kopicloud.user-crud.gen.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "reflect" kcapi "github.com/KopiCloud-AD-API/terraform-provider-ad/api" @@ -116,6 +117,15 @@ func resourceUser() *schema.Resource { Description: "", } + terraformSchema["new_password"] = &schema.Schema{ + Type: schema.TypeString, + Computed: false, + Optional: false, + Required: true, + + Description: "", + } + terraformSchema["change_password_net_logon"] = &schema.Schema{ Type: schema.TypeBool, Computed: false, @@ -263,9 +273,17 @@ func resourceUserCreate(ctx context.Context, d *schema.ResourceData, m interface api_result := res.JSON200.Result resItems := UserToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted User: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted User }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted User", + map[string]interface{}{ + "User": resItems, + }) } result := wrapInArray(resItems) @@ -341,9 +359,17 @@ func resourceUserRead(ctx context.Context, d *schema.ResourceData, m interface{} api_result := res.JSON200.Result resItems := UserToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted User: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted User }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted User", + map[string]interface{}{ + "User": resItems, + }) } result := wrapInArray(resItems) @@ -423,9 +449,17 @@ func resourceUserDelete(ctx context.Context, d *schema.ResourceData, m interface api_result := res.JSON200.Result resItems := UserToTerraform(api_result) - - for _, element := range resItems { - tflog.Debug(ctx, "converted User: %#v", element.(map[string]interface{})) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted User }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted User", + map[string]interface{}{ + "User": resItems, + }) } result := wrapInArray(resItems) diff --git a/provider/kopicloud.user-data.gen.go b/provider/kopicloud.user-data.gen.go index 3bfb2ae..d9ddce6 100644 --- a/provider/kopicloud.user-data.gen.go +++ b/provider/kopicloud.user-data.gen.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "reflect" kcapi "github.com/KopiCloud-AD-API/terraform-provider-ad/api" @@ -126,10 +127,16 @@ func dataSourceUser_Read_0(ctx context.Context, d *schema.ResourceData, m interf resItems := UserListToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted User }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted User", map[string]interface{}{ - "User": element, + "User": resItems, }) } @@ -212,10 +219,16 @@ func dataSourceUser_Read_1(ctx context.Context, d *schema.ResourceData, m interf resItems := UserListToTerraform(api_result) - for _, element := range resItems { + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted User }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted User", map[string]interface{}{ - "User": element, + "User": resItems, }) } diff --git a/provider/kopicloud.user-update.gen.go b/provider/kopicloud.user-update.gen.go index 5cc5357..d290df6 100644 --- a/provider/kopicloud.user-update.gen.go +++ b/provider/kopicloud.user-update.gen.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "reflect" kcapi "github.com/KopiCloud-AD-API/terraform-provider-ad/api" @@ -24,6 +25,14 @@ func resourceUserUpdate(ctx context.Context, d *schema.ResourceData, m interface result = resourceUser_Update_0(ctx, d, m) } + required_inputs = make([]string, 1) + + required_inputs[0] = "new_password" + + if checkFieldsModified(d, required_inputs) { + result = resourceUser_Update_1(ctx, d, m) + } + return result } @@ -127,11 +136,113 @@ func resourceUser_Update_0(ctx context.Context, d *schema.ResourceData, m interf api_result := res.JSON200.Result resItems := UserToTerraform(api_result) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted User }: %#v", element.(map[string]interface{})) + } + default: + tflog.Debug(ctx, "converted User", + map[string]interface{}{ + "User": resItems, + }) + } + + result := wrapInArray(resItems) + + if err := d.Set("result", result); err != nil { + return diag.FromErr(err) + } + + d.SetId(getId_for_User(api_result)) + + } + } else { + return diag.Errorf("No data found in db, insert one %s", "User") + } + + tflog.Debug(ctx, "dataSourceUserRead finished successfully", + map[string]interface{}{ + "result": d, + }) + return diags +} + +func resourceUser_Update_1(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + // Warning or errors can be collected in a slice type + tflog.Debug(ctx, fmt.Sprintf("Beginning dataSourceUser_Read_1")) + var diags diag.Diagnostics + c := m.(*ApiClient) + tflog.Debug(ctx, "Terraform data", map[string]interface{}{ + "client_data": c.data, + "schema_data": d, + }) + + new_password := getFieldValue("new_password", false, d).(string) + + change_password_net_logon := getFieldValue("change_password_net_logon", false, d).(bool) + + show_fields := getFieldValue("show_fields", false, d).(string) - for _, element := range resItems { + params := kcapi.PostApiADUserUsernameResetPasswordParams{ + AuthToken: c.data.Get("token").(string), + + NewPassword: &new_password, + + ChangePassword: &change_password_net_logon, + + ShowFields: &show_fields, + } + + username := getFieldValue("username", false, d).(string) + + res, err := c.client.PostApiADUserUsernameResetPasswordWithResponse( + ctx, + + username, + + ¶ms) + if err != nil { + return diag.FromErr(err) + } + + if res != nil { + if res.HTTPResponse.StatusCode != 200 { + if res.JSON200 == nil { + if json.Valid(res.Body) { + var result map[string]interface{} + json.Unmarshal(res.Body, &result) + if output, ok := result["output"]; ok { + tflog.Error(ctx, fmt.Sprintf("%s", output)) + return diag.Errorf(fmt.Sprintf("%s", output)) + } + } + tflog.Error(ctx, string(res.Body)) + return diag.Errorf(string(res.Body)) + } else { + + tflog.Error(ctx, *res.JSON200.Output) + return diag.Errorf(string(*res.JSON200.Output)) + + } + } else { + + tflog.Info(ctx, *res.JSON200.Output) + + api_result := res.JSON200.Result + + resItems := UserToTerraform(api_result) + rt := reflect.TypeOf(resItems) + switch rt.Kind() { + case reflect.Slice | reflect.Array: + for _, element := range resItems { + tflog.Debug(ctx, "converted User }: %#v", element.(map[string]interface{})) + } + default: tflog.Debug(ctx, "converted User", map[string]interface{}{ - "User": element, + "User": resItems, }) }