| // Copyright (c) HashiCorp, Inc. |
| // SPDX-License-Identifier: MPL-2.0 |
| |
| // ---------------------------------------------------------------------------- |
| // |
| // *** AUTO GENERATED CODE *** Type: MMv1 *** |
| // |
| // ---------------------------------------------------------------------------- |
| // |
| // This file is automatically generated by Magic Modules and manual |
| // changes will be clobbered when the file is regenerated. |
| // |
| // Please read more about how to change this file in |
| // .github/CONTRIBUTING.md. |
| // |
| // ---------------------------------------------------------------------------- |
| |
| package looker |
| |
| import ( |
| "fmt" |
| "log" |
| "reflect" |
| "strings" |
| "time" |
| |
| "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" |
| "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" |
| "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" |
| |
| "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource" |
| transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" |
| "github.com/hashicorp/terraform-provider-google-beta/google-beta/verify" |
| ) |
| |
| func ResourceLookerInstance() *schema.Resource { |
| return &schema.Resource{ |
| Create: resourceLookerInstanceCreate, |
| Read: resourceLookerInstanceRead, |
| Update: resourceLookerInstanceUpdate, |
| Delete: resourceLookerInstanceDelete, |
| |
| Importer: &schema.ResourceImporter{ |
| State: resourceLookerInstanceImport, |
| }, |
| |
| Timeouts: &schema.ResourceTimeout{ |
| Create: schema.DefaultTimeout(90 * time.Minute), |
| Update: schema.DefaultTimeout(90 * time.Minute), |
| Delete: schema.DefaultTimeout(90 * time.Minute), |
| }, |
| |
| CustomizeDiff: customdiff.All( |
| tpgresource.DefaultProviderProject, |
| ), |
| |
| Schema: map[string]*schema.Schema{ |
| "name": { |
| Type: schema.TypeString, |
| Required: true, |
| ForceNew: true, |
| ValidateFunc: verify.ValidateRegexp(`^[a-z][a-z0-9-]{0,39}[a-z0-9]$`), |
| Description: `The ID of the instance or a fully qualified identifier for the instance.`, |
| }, |
| "admin_settings": { |
| Type: schema.TypeList, |
| Optional: true, |
| Description: `Looker instance Admin settings.`, |
| MaxItems: 1, |
| Elem: &schema.Resource{ |
| Schema: map[string]*schema.Schema{ |
| "allowed_email_domains": { |
| Type: schema.TypeList, |
| Optional: true, |
| Description: `Email domain allowlist for the instance. |
| |
| Define the email domains to which your users can deliver Looker (Google Cloud core) content. |
| Updating this list will restart the instance. Updating the allowed email domains from terraform |
| means the value provided will be considered as the entire list and not an amendment to the |
| existing list of allowed email domains.`, |
| Elem: &schema.Schema{ |
| Type: schema.TypeString, |
| }, |
| }, |
| }, |
| }, |
| }, |
| "consumer_network": { |
| Type: schema.TypeString, |
| Optional: true, |
| Description: `Network name in the consumer project in the format of: projects/{project}/global/networks/{network} |
| Note that the consumer network may be in a different GCP project than the consumer |
| project that is hosting the Looker Instance.`, |
| }, |
| "custom_domain": { |
| Type: schema.TypeList, |
| Optional: true, |
| Description: `Custom domain settings for a Looker instance.`, |
| MaxItems: 1, |
| Elem: &schema.Resource{ |
| Schema: map[string]*schema.Schema{ |
| "domain": { |
| Type: schema.TypeString, |
| Optional: true, |
| Description: `Domain name`, |
| }, |
| "state": { |
| Type: schema.TypeString, |
| Computed: true, |
| Description: `Status of the custom domain.`, |
| }, |
| }, |
| }, |
| }, |
| "deny_maintenance_period": { |
| Type: schema.TypeList, |
| Optional: true, |
| Description: `Maintenance denial period for this instance. |
| |
| You must allow at least 14 days of maintenance availability |
| between any two deny maintenance periods.`, |
| MaxItems: 1, |
| Elem: &schema.Resource{ |
| Schema: map[string]*schema.Schema{ |
| "end_date": { |
| Type: schema.TypeList, |
| Required: true, |
| Description: `Required. Start date of the deny maintenance period`, |
| MaxItems: 1, |
| Elem: &schema.Resource{ |
| Schema: map[string]*schema.Schema{ |
| "day": { |
| Type: schema.TypeInt, |
| Optional: true, |
| ValidateFunc: validation.IntBetween(0, 32), |
| Description: `Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 |
| to specify a year by itself or a year and month where the day isn't significant.`, |
| }, |
| "month": { |
| Type: schema.TypeInt, |
| Optional: true, |
| ValidateFunc: validation.IntBetween(0, 13), |
| Description: `Month of a year. Must be from 1 to 12, or 0 to specify a year without a |
| month and day.`, |
| }, |
| "year": { |
| Type: schema.TypeInt, |
| Optional: true, |
| ValidateFunc: validation.IntBetween(0, 10000), |
| Description: `Year of the date. Must be from 1 to 9999, or 0 to specify a date without |
| a year.`, |
| }, |
| }, |
| }, |
| }, |
| "start_date": { |
| Type: schema.TypeList, |
| Required: true, |
| Description: `Required. Start date of the deny maintenance period`, |
| MaxItems: 1, |
| Elem: &schema.Resource{ |
| Schema: map[string]*schema.Schema{ |
| "day": { |
| Type: schema.TypeInt, |
| Optional: true, |
| ValidateFunc: validation.IntBetween(0, 32), |
| Description: `Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 |
| to specify a year by itself or a year and month where the day isn't significant.`, |
| }, |
| "month": { |
| Type: schema.TypeInt, |
| Optional: true, |
| ValidateFunc: validation.IntBetween(0, 13), |
| Description: `Month of a year. Must be from 1 to 12, or 0 to specify a year without a |
| month and day.`, |
| }, |
| "year": { |
| Type: schema.TypeInt, |
| Optional: true, |
| ValidateFunc: validation.IntBetween(0, 10000), |
| Description: `Year of the date. Must be from 1 to 9999, or 0 to specify a date without |
| a year.`, |
| }, |
| }, |
| }, |
| }, |
| "time": { |
| Type: schema.TypeList, |
| Required: true, |
| Description: `Required. Start time of the window in UTC time.`, |
| MaxItems: 1, |
| Elem: &schema.Resource{ |
| Schema: map[string]*schema.Schema{ |
| "hours": { |
| Type: schema.TypeInt, |
| Optional: true, |
| ValidateFunc: validation.IntBetween(0, 23), |
| Description: `Hours of day in 24 hour format. Should be from 0 to 23.`, |
| }, |
| "minutes": { |
| Type: schema.TypeInt, |
| Optional: true, |
| ValidateFunc: validation.IntBetween(0, 60), |
| Description: `Minutes of hour of day. Must be from 0 to 59.`, |
| }, |
| "nanos": { |
| Type: schema.TypeInt, |
| Optional: true, |
| ValidateFunc: validation.IntBetween(0, 999999999), |
| Description: `Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999.`, |
| }, |
| "seconds": { |
| Type: schema.TypeInt, |
| Optional: true, |
| ValidateFunc: validation.IntBetween(0, 60), |
| Description: `Seconds of minutes of the time. Must normally be from 0 to 59.`, |
| }, |
| }, |
| }, |
| }, |
| }, |
| }, |
| }, |
| "encryption_config": { |
| Type: schema.TypeList, |
| Computed: true, |
| Optional: true, |
| Description: `Looker instance encryption settings.`, |
| MaxItems: 1, |
| Elem: &schema.Resource{ |
| Schema: map[string]*schema.Schema{ |
| "kms_key_name": { |
| Type: schema.TypeString, |
| Optional: true, |
| Description: `Name of the customer managed encryption key (CMEK) in KMS.`, |
| }, |
| "kms_key_name_version": { |
| Type: schema.TypeString, |
| Computed: true, |
| Description: `Full name and version of the CMEK key currently in use to encrypt Looker data.`, |
| }, |
| "kms_key_state": { |
| Type: schema.TypeString, |
| Computed: true, |
| Description: `Status of the customer managed encryption key (CMEK) in KMS.`, |
| }, |
| }, |
| }, |
| }, |
| "maintenance_window": { |
| Type: schema.TypeList, |
| Optional: true, |
| Description: `Maintenance window for an instance. |
| |
| Maintenance of your instance takes place once a month, and will require |
| your instance to be restarted during updates, which will temporarily |
| disrupt service.`, |
| MaxItems: 1, |
| Elem: &schema.Resource{ |
| Schema: map[string]*schema.Schema{ |
| "day_of_week": { |
| Type: schema.TypeString, |
| Required: true, |
| ValidateFunc: verify.ValidateEnum([]string{"MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY"}), |
| Description: `Required. Day of the week for this MaintenanceWindow (in UTC). |
| |
| - MONDAY: Monday |
| - TUESDAY: Tuesday |
| - WEDNESDAY: Wednesday |
| - THURSDAY: Thursday |
| - FRIDAY: Friday |
| - SATURDAY: Saturday |
| - SUNDAY: Sunday Possible values: ["MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY"]`, |
| }, |
| "start_time": { |
| Type: schema.TypeList, |
| Required: true, |
| Description: `Required. Start time of the window in UTC time.`, |
| MaxItems: 1, |
| Elem: &schema.Resource{ |
| Schema: map[string]*schema.Schema{ |
| "hours": { |
| Type: schema.TypeInt, |
| Optional: true, |
| ValidateFunc: validation.IntBetween(0, 23), |
| Description: `Hours of day in 24 hour format. Should be from 0 to 23.`, |
| }, |
| "minutes": { |
| Type: schema.TypeInt, |
| Optional: true, |
| ValidateFunc: validation.IntBetween(0, 60), |
| Description: `Minutes of hour of day. Must be from 0 to 59.`, |
| }, |
| "nanos": { |
| Type: schema.TypeInt, |
| Optional: true, |
| ValidateFunc: validation.IntBetween(0, 999999999), |
| Description: `Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999.`, |
| }, |
| "seconds": { |
| Type: schema.TypeInt, |
| Optional: true, |
| ValidateFunc: validation.IntBetween(0, 60), |
| Description: `Seconds of minutes of the time. Must normally be from 0 to 59.`, |
| }, |
| }, |
| }, |
| }, |
| }, |
| }, |
| }, |
| "oauth_config": { |
| Type: schema.TypeList, |
| Optional: true, |
| Description: `Looker Instance OAuth login settings.`, |
| MaxItems: 1, |
| Elem: &schema.Resource{ |
| Schema: map[string]*schema.Schema{ |
| "client_id": { |
| Type: schema.TypeString, |
| Required: true, |
| Description: `The client ID for the Oauth config.`, |
| }, |
| "client_secret": { |
| Type: schema.TypeString, |
| Required: true, |
| Description: `The client secret for the Oauth config.`, |
| }, |
| }, |
| }, |
| }, |
| "platform_edition": { |
| Type: schema.TypeString, |
| Optional: true, |
| ForceNew: true, |
| ValidateFunc: verify.ValidateEnum([]string{"LOOKER_CORE_TRIAL", "LOOKER_CORE_STANDARD", "LOOKER_CORE_STANDARD_ANNUAL", "LOOKER_CORE_ENTERPRISE_ANNUAL", "LOOKER_CORE_EMBED_ANNUAL", ""}), |
| Description: `Platform editions for a Looker instance. Each edition maps to a set of instance features, like its size. Must be one of these values: |
| - LOOKER_CORE_TRIAL: trial instance |
| - LOOKER_CORE_STANDARD: pay as you go standard instance |
| - LOOKER_CORE_STANDARD_ANNUAL: subscription standard instance |
| - LOOKER_CORE_ENTERPRISE_ANNUAL: subscription enterprise instance |
| - LOOKER_CORE_EMBED_ANNUAL: subscription embed instance Default value: "LOOKER_CORE_TRIAL" Possible values: ["LOOKER_CORE_TRIAL", "LOOKER_CORE_STANDARD", "LOOKER_CORE_STANDARD_ANNUAL", "LOOKER_CORE_ENTERPRISE_ANNUAL", "LOOKER_CORE_EMBED_ANNUAL"]`, |
| Default: "LOOKER_CORE_TRIAL", |
| }, |
| "private_ip_enabled": { |
| Type: schema.TypeBool, |
| Optional: true, |
| Description: `Whether private IP is enabled on the Looker instance.`, |
| Default: false, |
| }, |
| "public_ip_enabled": { |
| Type: schema.TypeBool, |
| Optional: true, |
| Description: `Whether public IP is enabled on the Looker instance.`, |
| Default: true, |
| }, |
| "region": { |
| Type: schema.TypeString, |
| Computed: true, |
| Optional: true, |
| ForceNew: true, |
| Description: `The name of the Looker region of the instance.`, |
| }, |
| "reserved_range": { |
| Type: schema.TypeString, |
| Optional: true, |
| Description: `Name of a reserved IP address range within the consumer network, to be used for |
| private service access connection. User may or may not specify this in a request.`, |
| }, |
| "user_metadata": { |
| Type: schema.TypeList, |
| Optional: true, |
| Description: `Metadata about users for a Looker instance. |
| |
| These settings are only available when platform edition LOOKER_CORE_STANDARD is set. |
| |
| There are ten Standard and two Developer users included in the cost of the product. |
| You can allocate additional Standard, Viewer, and Developer users for this instance. |
| It is an optional step and can be modified later. |
| |
| With the Standard edition of Looker (Google Cloud core), you can provision up to 50 |
| total users, distributed across Viewer, Standard, and Developer.`, |
| MaxItems: 1, |
| Elem: &schema.Resource{ |
| Schema: map[string]*schema.Schema{ |
| "additional_developer_user_count": { |
| Type: schema.TypeInt, |
| Optional: true, |
| Description: `Number of additional Developer Users to allocate to the Looker Instance.`, |
| }, |
| "additional_standard_user_count": { |
| Type: schema.TypeInt, |
| Optional: true, |
| Description: `Number of additional Standard Users to allocate to the Looker Instance.`, |
| }, |
| "additional_viewer_user_count": { |
| Type: schema.TypeInt, |
| Optional: true, |
| Description: `Number of additional Viewer Users to allocate to the Looker Instance.`, |
| }, |
| }, |
| }, |
| }, |
| "create_time": { |
| Type: schema.TypeString, |
| Computed: true, |
| Description: `The time the instance was created in RFC3339 UTC "Zulu" format, |
| accurate to nanoseconds.`, |
| }, |
| "egress_public_ip": { |
| Type: schema.TypeString, |
| Computed: true, |
| Description: `Public Egress IP (IPv4).`, |
| }, |
| "ingress_private_ip": { |
| Type: schema.TypeString, |
| Computed: true, |
| Description: `Private Ingress IP (IPv4).`, |
| }, |
| "ingress_public_ip": { |
| Type: schema.TypeString, |
| Computed: true, |
| Description: `Public Ingress IP (IPv4).`, |
| }, |
| "looker_uri": { |
| Type: schema.TypeString, |
| Computed: true, |
| Description: `Looker instance URI which can be used to access the Looker Instance UI.`, |
| }, |
| "looker_version": { |
| Type: schema.TypeString, |
| Computed: true, |
| Description: `The Looker version that the instance is using.`, |
| }, |
| "update_time": { |
| Type: schema.TypeString, |
| Computed: true, |
| Description: `The time the instance was updated in RFC3339 UTC "Zulu" format, |
| accurate to nanoseconds.`, |
| }, |
| "project": { |
| Type: schema.TypeString, |
| Optional: true, |
| Computed: true, |
| ForceNew: true, |
| }, |
| }, |
| UseJSONNumber: true, |
| } |
| } |
| |
| func resourceLookerInstanceCreate(d *schema.ResourceData, meta interface{}) error { |
| config := meta.(*transport_tpg.Config) |
| userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) |
| if err != nil { |
| return err |
| } |
| |
| obj := make(map[string]interface{}) |
| adminSettingsProp, err := expandLookerInstanceAdminSettings(d.Get("admin_settings"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("admin_settings"); !tpgresource.IsEmptyValue(reflect.ValueOf(adminSettingsProp)) && (ok || !reflect.DeepEqual(v, adminSettingsProp)) { |
| obj["adminSettings"] = adminSettingsProp |
| } |
| consumerNetworkProp, err := expandLookerInstanceConsumerNetwork(d.Get("consumer_network"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("consumer_network"); !tpgresource.IsEmptyValue(reflect.ValueOf(consumerNetworkProp)) && (ok || !reflect.DeepEqual(v, consumerNetworkProp)) { |
| obj["consumerNetwork"] = consumerNetworkProp |
| } |
| denyMaintenancePeriodProp, err := expandLookerInstanceDenyMaintenancePeriod(d.Get("deny_maintenance_period"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("deny_maintenance_period"); !tpgresource.IsEmptyValue(reflect.ValueOf(denyMaintenancePeriodProp)) && (ok || !reflect.DeepEqual(v, denyMaintenancePeriodProp)) { |
| obj["denyMaintenancePeriod"] = denyMaintenancePeriodProp |
| } |
| encryptionConfigProp, err := expandLookerInstanceEncryptionConfig(d.Get("encryption_config"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("encryption_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(encryptionConfigProp)) && (ok || !reflect.DeepEqual(v, encryptionConfigProp)) { |
| obj["encryptionConfig"] = encryptionConfigProp |
| } |
| maintenanceWindowProp, err := expandLookerInstanceMaintenanceWindow(d.Get("maintenance_window"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("maintenance_window"); !tpgresource.IsEmptyValue(reflect.ValueOf(maintenanceWindowProp)) && (ok || !reflect.DeepEqual(v, maintenanceWindowProp)) { |
| obj["maintenanceWindow"] = maintenanceWindowProp |
| } |
| oauthConfigProp, err := expandLookerInstanceOauthConfig(d.Get("oauth_config"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("oauth_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(oauthConfigProp)) && (ok || !reflect.DeepEqual(v, oauthConfigProp)) { |
| obj["oauthConfig"] = oauthConfigProp |
| } |
| platformEditionProp, err := expandLookerInstancePlatformEdition(d.Get("platform_edition"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("platform_edition"); !tpgresource.IsEmptyValue(reflect.ValueOf(platformEditionProp)) && (ok || !reflect.DeepEqual(v, platformEditionProp)) { |
| obj["platformEdition"] = platformEditionProp |
| } |
| privateIpEnabledProp, err := expandLookerInstancePrivateIpEnabled(d.Get("private_ip_enabled"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("private_ip_enabled"); !tpgresource.IsEmptyValue(reflect.ValueOf(privateIpEnabledProp)) && (ok || !reflect.DeepEqual(v, privateIpEnabledProp)) { |
| obj["privateIpEnabled"] = privateIpEnabledProp |
| } |
| publicIpEnabledProp, err := expandLookerInstancePublicIpEnabled(d.Get("public_ip_enabled"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("public_ip_enabled"); !tpgresource.IsEmptyValue(reflect.ValueOf(publicIpEnabledProp)) && (ok || !reflect.DeepEqual(v, publicIpEnabledProp)) { |
| obj["publicIpEnabled"] = publicIpEnabledProp |
| } |
| reservedRangeProp, err := expandLookerInstanceReservedRange(d.Get("reserved_range"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("reserved_range"); !tpgresource.IsEmptyValue(reflect.ValueOf(reservedRangeProp)) && (ok || !reflect.DeepEqual(v, reservedRangeProp)) { |
| obj["reservedRange"] = reservedRangeProp |
| } |
| userMetadataProp, err := expandLookerInstanceUserMetadata(d.Get("user_metadata"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("user_metadata"); !tpgresource.IsEmptyValue(reflect.ValueOf(userMetadataProp)) && (ok || !reflect.DeepEqual(v, userMetadataProp)) { |
| obj["userMetadata"] = userMetadataProp |
| } |
| customDomainProp, err := expandLookerInstanceCustomDomain(d.Get("custom_domain"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("custom_domain"); !tpgresource.IsEmptyValue(reflect.ValueOf(customDomainProp)) && (ok || !reflect.DeepEqual(v, customDomainProp)) { |
| obj["customDomain"] = customDomainProp |
| } |
| |
| url, err := tpgresource.ReplaceVars(d, config, "{{LookerBasePath}}projects/{{project}}/locations/{{region}}/instances?instanceId={{name}}") |
| if err != nil { |
| return err |
| } |
| |
| log.Printf("[DEBUG] Creating new Instance: %#v", obj) |
| billingProject := "" |
| |
| project, err := tpgresource.GetProject(d, config) |
| if err != nil { |
| return fmt.Errorf("Error fetching project for Instance: %s", err) |
| } |
| billingProject = project |
| |
| // err == nil indicates that the billing_project value was found |
| if bp, err := tpgresource.GetBillingProject(d, config); err == nil { |
| billingProject = bp |
| } |
| |
| res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ |
| Config: config, |
| Method: "POST", |
| Project: billingProject, |
| RawURL: url, |
| UserAgent: userAgent, |
| Body: obj, |
| Timeout: d.Timeout(schema.TimeoutCreate), |
| ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, |
| }) |
| if err != nil { |
| return fmt.Errorf("Error creating Instance: %s", err) |
| } |
| |
| // Store the ID now |
| id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{region}}/instances/{{name}}") |
| if err != nil { |
| return fmt.Errorf("Error constructing id: %s", err) |
| } |
| d.SetId(id) |
| |
| // Use the resource in the operation response to populate |
| // identity fields and d.Id() before read |
| var opRes map[string]interface{} |
| err = LookerOperationWaitTimeWithResponse( |
| config, res, &opRes, project, "Creating Instance", userAgent, |
| d.Timeout(schema.TimeoutCreate)) |
| if err != nil { |
| // The resource didn't actually create |
| d.SetId("") |
| |
| return fmt.Errorf("Error waiting to create Instance: %s", err) |
| } |
| |
| // This may have caused the ID to update - update it if so. |
| id, err = tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{region}}/instances/{{name}}") |
| if err != nil { |
| return fmt.Errorf("Error constructing id: %s", err) |
| } |
| d.SetId(id) |
| |
| log.Printf("[DEBUG] Finished creating Instance %q: %#v", d.Id(), res) |
| |
| return resourceLookerInstanceRead(d, meta) |
| } |
| |
| func resourceLookerInstanceRead(d *schema.ResourceData, meta interface{}) error { |
| config := meta.(*transport_tpg.Config) |
| userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) |
| if err != nil { |
| return err |
| } |
| |
| url, err := tpgresource.ReplaceVars(d, config, "{{LookerBasePath}}projects/{{project}}/locations/{{region}}/instances/{{name}}") |
| if err != nil { |
| return err |
| } |
| |
| billingProject := "" |
| |
| project, err := tpgresource.GetProject(d, config) |
| if err != nil { |
| return fmt.Errorf("Error fetching project for Instance: %s", err) |
| } |
| billingProject = project |
| |
| // err == nil indicates that the billing_project value was found |
| if bp, err := tpgresource.GetBillingProject(d, config); err == nil { |
| billingProject = bp |
| } |
| |
| res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ |
| Config: config, |
| Method: "GET", |
| Project: billingProject, |
| RawURL: url, |
| UserAgent: userAgent, |
| ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, |
| }) |
| if err != nil { |
| return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("LookerInstance %q", d.Id())) |
| } |
| |
| if err := d.Set("project", project); err != nil { |
| return fmt.Errorf("Error reading Instance: %s", err) |
| } |
| |
| if err := d.Set("admin_settings", flattenLookerInstanceAdminSettings(res["adminSettings"], d, config)); err != nil { |
| return fmt.Errorf("Error reading Instance: %s", err) |
| } |
| if err := d.Set("consumer_network", flattenLookerInstanceConsumerNetwork(res["consumerNetwork"], d, config)); err != nil { |
| return fmt.Errorf("Error reading Instance: %s", err) |
| } |
| if err := d.Set("create_time", flattenLookerInstanceCreateTime(res["createTime"], d, config)); err != nil { |
| return fmt.Errorf("Error reading Instance: %s", err) |
| } |
| if err := d.Set("deny_maintenance_period", flattenLookerInstanceDenyMaintenancePeriod(res["denyMaintenancePeriod"], d, config)); err != nil { |
| return fmt.Errorf("Error reading Instance: %s", err) |
| } |
| if err := d.Set("egress_public_ip", flattenLookerInstanceEgressPublicIp(res["egressPublicIp"], d, config)); err != nil { |
| return fmt.Errorf("Error reading Instance: %s", err) |
| } |
| if err := d.Set("encryption_config", flattenLookerInstanceEncryptionConfig(res["encryptionConfig"], d, config)); err != nil { |
| return fmt.Errorf("Error reading Instance: %s", err) |
| } |
| if err := d.Set("ingress_private_ip", flattenLookerInstanceIngressPrivateIp(res["ingressPrivateIp"], d, config)); err != nil { |
| return fmt.Errorf("Error reading Instance: %s", err) |
| } |
| if err := d.Set("ingress_public_ip", flattenLookerInstanceIngressPublicIp(res["ingressPublicIp"], d, config)); err != nil { |
| return fmt.Errorf("Error reading Instance: %s", err) |
| } |
| if err := d.Set("looker_version", flattenLookerInstanceLookerVersion(res["lookerVersion"], d, config)); err != nil { |
| return fmt.Errorf("Error reading Instance: %s", err) |
| } |
| if err := d.Set("looker_uri", flattenLookerInstanceLookerUri(res["lookerUri"], d, config)); err != nil { |
| return fmt.Errorf("Error reading Instance: %s", err) |
| } |
| if err := d.Set("maintenance_window", flattenLookerInstanceMaintenanceWindow(res["maintenanceWindow"], d, config)); err != nil { |
| return fmt.Errorf("Error reading Instance: %s", err) |
| } |
| if err := d.Set("platform_edition", flattenLookerInstancePlatformEdition(res["platformEdition"], d, config)); err != nil { |
| return fmt.Errorf("Error reading Instance: %s", err) |
| } |
| if err := d.Set("private_ip_enabled", flattenLookerInstancePrivateIpEnabled(res["privateIpEnabled"], d, config)); err != nil { |
| return fmt.Errorf("Error reading Instance: %s", err) |
| } |
| if err := d.Set("public_ip_enabled", flattenLookerInstancePublicIpEnabled(res["publicIpEnabled"], d, config)); err != nil { |
| return fmt.Errorf("Error reading Instance: %s", err) |
| } |
| if err := d.Set("reserved_range", flattenLookerInstanceReservedRange(res["reservedRange"], d, config)); err != nil { |
| return fmt.Errorf("Error reading Instance: %s", err) |
| } |
| if err := d.Set("update_time", flattenLookerInstanceUpdateTime(res["updateTime"], d, config)); err != nil { |
| return fmt.Errorf("Error reading Instance: %s", err) |
| } |
| if err := d.Set("user_metadata", flattenLookerInstanceUserMetadata(res["userMetadata"], d, config)); err != nil { |
| return fmt.Errorf("Error reading Instance: %s", err) |
| } |
| if err := d.Set("custom_domain", flattenLookerInstanceCustomDomain(res["customDomain"], d, config)); err != nil { |
| return fmt.Errorf("Error reading Instance: %s", err) |
| } |
| |
| return nil |
| } |
| |
| func resourceLookerInstanceUpdate(d *schema.ResourceData, meta interface{}) error { |
| config := meta.(*transport_tpg.Config) |
| userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) |
| if err != nil { |
| return err |
| } |
| |
| billingProject := "" |
| |
| project, err := tpgresource.GetProject(d, config) |
| if err != nil { |
| return fmt.Errorf("Error fetching project for Instance: %s", err) |
| } |
| billingProject = project |
| |
| obj := make(map[string]interface{}) |
| adminSettingsProp, err := expandLookerInstanceAdminSettings(d.Get("admin_settings"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("admin_settings"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, adminSettingsProp)) { |
| obj["adminSettings"] = adminSettingsProp |
| } |
| consumerNetworkProp, err := expandLookerInstanceConsumerNetwork(d.Get("consumer_network"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("consumer_network"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, consumerNetworkProp)) { |
| obj["consumerNetwork"] = consumerNetworkProp |
| } |
| denyMaintenancePeriodProp, err := expandLookerInstanceDenyMaintenancePeriod(d.Get("deny_maintenance_period"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("deny_maintenance_period"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, denyMaintenancePeriodProp)) { |
| obj["denyMaintenancePeriod"] = denyMaintenancePeriodProp |
| } |
| encryptionConfigProp, err := expandLookerInstanceEncryptionConfig(d.Get("encryption_config"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("encryption_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, encryptionConfigProp)) { |
| obj["encryptionConfig"] = encryptionConfigProp |
| } |
| maintenanceWindowProp, err := expandLookerInstanceMaintenanceWindow(d.Get("maintenance_window"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("maintenance_window"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, maintenanceWindowProp)) { |
| obj["maintenanceWindow"] = maintenanceWindowProp |
| } |
| oauthConfigProp, err := expandLookerInstanceOauthConfig(d.Get("oauth_config"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("oauth_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, oauthConfigProp)) { |
| obj["oauthConfig"] = oauthConfigProp |
| } |
| privateIpEnabledProp, err := expandLookerInstancePrivateIpEnabled(d.Get("private_ip_enabled"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("private_ip_enabled"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, privateIpEnabledProp)) { |
| obj["privateIpEnabled"] = privateIpEnabledProp |
| } |
| publicIpEnabledProp, err := expandLookerInstancePublicIpEnabled(d.Get("public_ip_enabled"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("public_ip_enabled"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, publicIpEnabledProp)) { |
| obj["publicIpEnabled"] = publicIpEnabledProp |
| } |
| reservedRangeProp, err := expandLookerInstanceReservedRange(d.Get("reserved_range"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("reserved_range"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, reservedRangeProp)) { |
| obj["reservedRange"] = reservedRangeProp |
| } |
| userMetadataProp, err := expandLookerInstanceUserMetadata(d.Get("user_metadata"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("user_metadata"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, userMetadataProp)) { |
| obj["userMetadata"] = userMetadataProp |
| } |
| customDomainProp, err := expandLookerInstanceCustomDomain(d.Get("custom_domain"), d, config) |
| if err != nil { |
| return err |
| } else if v, ok := d.GetOkExists("custom_domain"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, customDomainProp)) { |
| obj["customDomain"] = customDomainProp |
| } |
| |
| url, err := tpgresource.ReplaceVars(d, config, "{{LookerBasePath}}projects/{{project}}/locations/{{region}}/instances/{{name}}") |
| if err != nil { |
| return err |
| } |
| |
| log.Printf("[DEBUG] Updating Instance %q: %#v", d.Id(), obj) |
| updateMask := []string{} |
| |
| if d.HasChange("admin_settings") { |
| updateMask = append(updateMask, "admin_settings.allowed_email_domains") |
| } |
| |
| if d.HasChange("consumer_network") { |
| updateMask = append(updateMask, "consumerNetwork") |
| } |
| |
| if d.HasChange("deny_maintenance_period") { |
| updateMask = append(updateMask, "denyMaintenancePeriod") |
| } |
| |
| if d.HasChange("encryption_config") { |
| updateMask = append(updateMask, "encryptionConfig") |
| } |
| |
| if d.HasChange("maintenance_window") { |
| updateMask = append(updateMask, "maintenanceWindow") |
| } |
| |
| if d.HasChange("oauth_config") { |
| updateMask = append(updateMask, "oauthConfig") |
| } |
| |
| if d.HasChange("private_ip_enabled") { |
| updateMask = append(updateMask, "privateIpEnabled") |
| } |
| |
| if d.HasChange("public_ip_enabled") { |
| updateMask = append(updateMask, "publicIpEnabled") |
| } |
| |
| if d.HasChange("reserved_range") { |
| updateMask = append(updateMask, "reservedRange") |
| } |
| |
| if d.HasChange("user_metadata") { |
| updateMask = append(updateMask, "userMetadata") |
| } |
| |
| if d.HasChange("custom_domain") { |
| updateMask = append(updateMask, "customDomain") |
| } |
| // updateMask is a URL parameter but not present in the schema, so ReplaceVars |
| // won't set it |
| url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) |
| if err != nil { |
| return err |
| } |
| |
| // err == nil indicates that the billing_project value was found |
| if bp, err := tpgresource.GetBillingProject(d, config); err == nil { |
| billingProject = bp |
| } |
| |
| // if updateMask is empty we are not updating anything so skip the post |
| if len(updateMask) > 0 { |
| res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ |
| Config: config, |
| Method: "PATCH", |
| Project: billingProject, |
| RawURL: url, |
| UserAgent: userAgent, |
| Body: obj, |
| Timeout: d.Timeout(schema.TimeoutUpdate), |
| ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, |
| }) |
| |
| if err != nil { |
| return fmt.Errorf("Error updating Instance %q: %s", d.Id(), err) |
| } else { |
| log.Printf("[DEBUG] Finished updating Instance %q: %#v", d.Id(), res) |
| } |
| |
| err = LookerOperationWaitTime( |
| config, res, project, "Updating Instance", userAgent, |
| d.Timeout(schema.TimeoutUpdate)) |
| |
| if err != nil { |
| return err |
| } |
| } |
| |
| return resourceLookerInstanceRead(d, meta) |
| } |
| |
| func resourceLookerInstanceDelete(d *schema.ResourceData, meta interface{}) error { |
| config := meta.(*transport_tpg.Config) |
| userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) |
| if err != nil { |
| return err |
| } |
| |
| billingProject := "" |
| |
| project, err := tpgresource.GetProject(d, config) |
| if err != nil { |
| return fmt.Errorf("Error fetching project for Instance: %s", err) |
| } |
| billingProject = project |
| |
| url, err := tpgresource.ReplaceVars(d, config, "{{LookerBasePath}}projects/{{project}}/locations/{{region}}/instances/{{name}}") |
| if err != nil { |
| return err |
| } |
| |
| var obj map[string]interface{} |
| log.Printf("[DEBUG] Deleting Instance %q", d.Id()) |
| |
| // err == nil indicates that the billing_project value was found |
| if bp, err := tpgresource.GetBillingProject(d, config); err == nil { |
| billingProject = bp |
| } |
| |
| res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ |
| Config: config, |
| Method: "DELETE", |
| Project: billingProject, |
| RawURL: url, |
| UserAgent: userAgent, |
| Body: obj, |
| Timeout: d.Timeout(schema.TimeoutDelete), |
| ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, |
| }) |
| if err != nil { |
| return transport_tpg.HandleNotFoundError(err, d, "Instance") |
| } |
| |
| err = LookerOperationWaitTime( |
| config, res, project, "Deleting Instance", userAgent, |
| d.Timeout(schema.TimeoutDelete)) |
| |
| if err != nil { |
| return err |
| } |
| |
| log.Printf("[DEBUG] Finished deleting Instance %q: %#v", d.Id(), res) |
| return nil |
| } |
| |
| func resourceLookerInstanceImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { |
| config := meta.(*transport_tpg.Config) |
| if err := tpgresource.ParseImportId([]string{ |
| "^projects/(?P<project>[^/]+)/locations/(?P<region>[^/]+)/instances/(?P<name>[^/]+)$", |
| "^(?P<project>[^/]+)/(?P<region>[^/]+)/(?P<name>[^/]+)$", |
| "^(?P<region>[^/]+)/(?P<name>[^/]+)$", |
| "^(?P<name>[^/]+)$", |
| }, d, config); err != nil { |
| return nil, err |
| } |
| |
| // Replace import id for the resource id |
| id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{region}}/instances/{{name}}") |
| if err != nil { |
| return nil, fmt.Errorf("Error constructing id: %s", err) |
| } |
| d.SetId(id) |
| |
| return []*schema.ResourceData{d}, nil |
| } |
| |
| func flattenLookerInstanceAdminSettings(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| if v == nil { |
| return nil |
| } |
| original := v.(map[string]interface{}) |
| if len(original) == 0 { |
| return nil |
| } |
| transformed := make(map[string]interface{}) |
| transformed["allowed_email_domains"] = |
| flattenLookerInstanceAdminSettingsAllowedEmailDomains(original["allowedEmailDomains"], d, config) |
| return []interface{}{transformed} |
| } |
| func flattenLookerInstanceAdminSettingsAllowedEmailDomains(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenLookerInstanceConsumerNetwork(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenLookerInstanceCreateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenLookerInstanceDenyMaintenancePeriod(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| if v == nil { |
| return nil |
| } |
| original := v.(map[string]interface{}) |
| if len(original) == 0 { |
| return nil |
| } |
| transformed := make(map[string]interface{}) |
| transformed["start_date"] = |
| flattenLookerInstanceDenyMaintenancePeriodStartDate(original["startDate"], d, config) |
| transformed["end_date"] = |
| flattenLookerInstanceDenyMaintenancePeriodEndDate(original["endDate"], d, config) |
| transformed["time"] = |
| flattenLookerInstanceDenyMaintenancePeriodTime(original["time"], d, config) |
| return []interface{}{transformed} |
| } |
| func flattenLookerInstanceDenyMaintenancePeriodStartDate(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| if v == nil { |
| return nil |
| } |
| original := v.(map[string]interface{}) |
| if len(original) == 0 { |
| return nil |
| } |
| transformed := make(map[string]interface{}) |
| transformed["year"] = |
| flattenLookerInstanceDenyMaintenancePeriodStartDateYear(original["year"], d, config) |
| transformed["month"] = |
| flattenLookerInstanceDenyMaintenancePeriodStartDateMonth(original["month"], d, config) |
| transformed["day"] = |
| flattenLookerInstanceDenyMaintenancePeriodStartDateDay(original["day"], d, config) |
| return []interface{}{transformed} |
| } |
| func flattenLookerInstanceDenyMaintenancePeriodStartDateYear(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| // Handles the string fixed64 format |
| if strVal, ok := v.(string); ok { |
| if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { |
| return intVal |
| } |
| } |
| |
| // number values are represented as float64 |
| if floatVal, ok := v.(float64); ok { |
| intVal := int(floatVal) |
| return intVal |
| } |
| |
| return v // let terraform core handle it otherwise |
| } |
| |
| func flattenLookerInstanceDenyMaintenancePeriodStartDateMonth(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| // Handles the string fixed64 format |
| if strVal, ok := v.(string); ok { |
| if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { |
| return intVal |
| } |
| } |
| |
| // number values are represented as float64 |
| if floatVal, ok := v.(float64); ok { |
| intVal := int(floatVal) |
| return intVal |
| } |
| |
| return v // let terraform core handle it otherwise |
| } |
| |
| func flattenLookerInstanceDenyMaintenancePeriodStartDateDay(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| // Handles the string fixed64 format |
| if strVal, ok := v.(string); ok { |
| if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { |
| return intVal |
| } |
| } |
| |
| // number values are represented as float64 |
| if floatVal, ok := v.(float64); ok { |
| intVal := int(floatVal) |
| return intVal |
| } |
| |
| return v // let terraform core handle it otherwise |
| } |
| |
| func flattenLookerInstanceDenyMaintenancePeriodEndDate(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| if v == nil { |
| return nil |
| } |
| original := v.(map[string]interface{}) |
| if len(original) == 0 { |
| return nil |
| } |
| transformed := make(map[string]interface{}) |
| transformed["year"] = |
| flattenLookerInstanceDenyMaintenancePeriodEndDateYear(original["year"], d, config) |
| transformed["month"] = |
| flattenLookerInstanceDenyMaintenancePeriodEndDateMonth(original["month"], d, config) |
| transformed["day"] = |
| flattenLookerInstanceDenyMaintenancePeriodEndDateDay(original["day"], d, config) |
| return []interface{}{transformed} |
| } |
| func flattenLookerInstanceDenyMaintenancePeriodEndDateYear(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| // Handles the string fixed64 format |
| if strVal, ok := v.(string); ok { |
| if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { |
| return intVal |
| } |
| } |
| |
| // number values are represented as float64 |
| if floatVal, ok := v.(float64); ok { |
| intVal := int(floatVal) |
| return intVal |
| } |
| |
| return v // let terraform core handle it otherwise |
| } |
| |
| func flattenLookerInstanceDenyMaintenancePeriodEndDateMonth(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| // Handles the string fixed64 format |
| if strVal, ok := v.(string); ok { |
| if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { |
| return intVal |
| } |
| } |
| |
| // number values are represented as float64 |
| if floatVal, ok := v.(float64); ok { |
| intVal := int(floatVal) |
| return intVal |
| } |
| |
| return v // let terraform core handle it otherwise |
| } |
| |
| func flattenLookerInstanceDenyMaintenancePeriodEndDateDay(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| // Handles the string fixed64 format |
| if strVal, ok := v.(string); ok { |
| if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { |
| return intVal |
| } |
| } |
| |
| // number values are represented as float64 |
| if floatVal, ok := v.(float64); ok { |
| intVal := int(floatVal) |
| return intVal |
| } |
| |
| return v // let terraform core handle it otherwise |
| } |
| |
| func flattenLookerInstanceDenyMaintenancePeriodTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| if v == nil { |
| return nil |
| } |
| original := v.(map[string]interface{}) |
| if len(original) == 0 { |
| return nil |
| } |
| transformed := make(map[string]interface{}) |
| transformed["hours"] = |
| flattenLookerInstanceDenyMaintenancePeriodTimeHours(original["hours"], d, config) |
| transformed["minutes"] = |
| flattenLookerInstanceDenyMaintenancePeriodTimeMinutes(original["minutes"], d, config) |
| transformed["seconds"] = |
| flattenLookerInstanceDenyMaintenancePeriodTimeSeconds(original["seconds"], d, config) |
| transformed["nanos"] = |
| flattenLookerInstanceDenyMaintenancePeriodTimeNanos(original["nanos"], d, config) |
| return []interface{}{transformed} |
| } |
| func flattenLookerInstanceDenyMaintenancePeriodTimeHours(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| // Handles the string fixed64 format |
| if strVal, ok := v.(string); ok { |
| if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { |
| return intVal |
| } |
| } |
| |
| // number values are represented as float64 |
| if floatVal, ok := v.(float64); ok { |
| intVal := int(floatVal) |
| return intVal |
| } |
| |
| return v // let terraform core handle it otherwise |
| } |
| |
| func flattenLookerInstanceDenyMaintenancePeriodTimeMinutes(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| // Handles the string fixed64 format |
| if strVal, ok := v.(string); ok { |
| if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { |
| return intVal |
| } |
| } |
| |
| // number values are represented as float64 |
| if floatVal, ok := v.(float64); ok { |
| intVal := int(floatVal) |
| return intVal |
| } |
| |
| return v // let terraform core handle it otherwise |
| } |
| |
| func flattenLookerInstanceDenyMaintenancePeriodTimeSeconds(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| // Handles the string fixed64 format |
| if strVal, ok := v.(string); ok { |
| if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { |
| return intVal |
| } |
| } |
| |
| // number values are represented as float64 |
| if floatVal, ok := v.(float64); ok { |
| intVal := int(floatVal) |
| return intVal |
| } |
| |
| return v // let terraform core handle it otherwise |
| } |
| |
| func flattenLookerInstanceDenyMaintenancePeriodTimeNanos(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| // Handles the string fixed64 format |
| if strVal, ok := v.(string); ok { |
| if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { |
| return intVal |
| } |
| } |
| |
| // number values are represented as float64 |
| if floatVal, ok := v.(float64); ok { |
| intVal := int(floatVal) |
| return intVal |
| } |
| |
| return v // let terraform core handle it otherwise |
| } |
| |
| func flattenLookerInstanceEgressPublicIp(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenLookerInstanceEncryptionConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| if v == nil { |
| return nil |
| } |
| original := v.(map[string]interface{}) |
| if len(original) == 0 { |
| return nil |
| } |
| transformed := make(map[string]interface{}) |
| transformed["kms_key_name"] = |
| flattenLookerInstanceEncryptionConfigKmsKeyName(original["kmsKeyName"], d, config) |
| transformed["kms_key_state"] = |
| flattenLookerInstanceEncryptionConfigKmsKeyState(original["kmsKeyState"], d, config) |
| transformed["kms_key_name_version"] = |
| flattenLookerInstanceEncryptionConfigKmsKeyNameVersion(original["kmsKeyNameVersion"], d, config) |
| return []interface{}{transformed} |
| } |
| func flattenLookerInstanceEncryptionConfigKmsKeyName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenLookerInstanceEncryptionConfigKmsKeyState(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenLookerInstanceEncryptionConfigKmsKeyNameVersion(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenLookerInstanceIngressPrivateIp(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenLookerInstanceIngressPublicIp(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenLookerInstanceLookerVersion(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenLookerInstanceLookerUri(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenLookerInstanceMaintenanceWindow(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| if v == nil { |
| return nil |
| } |
| original := v.(map[string]interface{}) |
| if len(original) == 0 { |
| return nil |
| } |
| transformed := make(map[string]interface{}) |
| transformed["day_of_week"] = |
| flattenLookerInstanceMaintenanceWindowDayOfWeek(original["dayOfWeek"], d, config) |
| transformed["start_time"] = |
| flattenLookerInstanceMaintenanceWindowStartTime(original["startTime"], d, config) |
| return []interface{}{transformed} |
| } |
| func flattenLookerInstanceMaintenanceWindowDayOfWeek(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenLookerInstanceMaintenanceWindowStartTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| if v == nil { |
| return nil |
| } |
| original := v.(map[string]interface{}) |
| if len(original) == 0 { |
| return nil |
| } |
| transformed := make(map[string]interface{}) |
| transformed["hours"] = |
| flattenLookerInstanceMaintenanceWindowStartTimeHours(original["hours"], d, config) |
| transformed["minutes"] = |
| flattenLookerInstanceMaintenanceWindowStartTimeMinutes(original["minutes"], d, config) |
| transformed["seconds"] = |
| flattenLookerInstanceMaintenanceWindowStartTimeSeconds(original["seconds"], d, config) |
| transformed["nanos"] = |
| flattenLookerInstanceMaintenanceWindowStartTimeNanos(original["nanos"], d, config) |
| return []interface{}{transformed} |
| } |
| func flattenLookerInstanceMaintenanceWindowStartTimeHours(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| // Handles the string fixed64 format |
| if strVal, ok := v.(string); ok { |
| if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { |
| return intVal |
| } |
| } |
| |
| // number values are represented as float64 |
| if floatVal, ok := v.(float64); ok { |
| intVal := int(floatVal) |
| return intVal |
| } |
| |
| return v // let terraform core handle it otherwise |
| } |
| |
| func flattenLookerInstanceMaintenanceWindowStartTimeMinutes(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| // Handles the string fixed64 format |
| if strVal, ok := v.(string); ok { |
| if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { |
| return intVal |
| } |
| } |
| |
| // number values are represented as float64 |
| if floatVal, ok := v.(float64); ok { |
| intVal := int(floatVal) |
| return intVal |
| } |
| |
| return v // let terraform core handle it otherwise |
| } |
| |
| func flattenLookerInstanceMaintenanceWindowStartTimeSeconds(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| // Handles the string fixed64 format |
| if strVal, ok := v.(string); ok { |
| if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { |
| return intVal |
| } |
| } |
| |
| // number values are represented as float64 |
| if floatVal, ok := v.(float64); ok { |
| intVal := int(floatVal) |
| return intVal |
| } |
| |
| return v // let terraform core handle it otherwise |
| } |
| |
| func flattenLookerInstanceMaintenanceWindowStartTimeNanos(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| // Handles the string fixed64 format |
| if strVal, ok := v.(string); ok { |
| if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { |
| return intVal |
| } |
| } |
| |
| // number values are represented as float64 |
| if floatVal, ok := v.(float64); ok { |
| intVal := int(floatVal) |
| return intVal |
| } |
| |
| return v // let terraform core handle it otherwise |
| } |
| |
| func flattenLookerInstancePlatformEdition(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenLookerInstancePrivateIpEnabled(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenLookerInstancePublicIpEnabled(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenLookerInstanceReservedRange(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenLookerInstanceUpdateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenLookerInstanceUserMetadata(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| if v == nil { |
| return nil |
| } |
| original := v.(map[string]interface{}) |
| if len(original) == 0 { |
| return nil |
| } |
| transformed := make(map[string]interface{}) |
| transformed["additional_viewer_user_count"] = |
| flattenLookerInstanceUserMetadataAdditionalViewerUserCount(original["additionalViewerUserCount"], d, config) |
| transformed["additional_standard_user_count"] = |
| flattenLookerInstanceUserMetadataAdditionalStandardUserCount(original["additionalStandardUserCount"], d, config) |
| transformed["additional_developer_user_count"] = |
| flattenLookerInstanceUserMetadataAdditionalDeveloperUserCount(original["additionalDeveloperUserCount"], d, config) |
| return []interface{}{transformed} |
| } |
| func flattenLookerInstanceUserMetadataAdditionalViewerUserCount(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| // Handles the string fixed64 format |
| if strVal, ok := v.(string); ok { |
| if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { |
| return intVal |
| } |
| } |
| |
| // number values are represented as float64 |
| if floatVal, ok := v.(float64); ok { |
| intVal := int(floatVal) |
| return intVal |
| } |
| |
| return v // let terraform core handle it otherwise |
| } |
| |
| func flattenLookerInstanceUserMetadataAdditionalStandardUserCount(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| // Handles the string fixed64 format |
| if strVal, ok := v.(string); ok { |
| if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { |
| return intVal |
| } |
| } |
| |
| // number values are represented as float64 |
| if floatVal, ok := v.(float64); ok { |
| intVal := int(floatVal) |
| return intVal |
| } |
| |
| return v // let terraform core handle it otherwise |
| } |
| |
| func flattenLookerInstanceUserMetadataAdditionalDeveloperUserCount(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| // Handles the string fixed64 format |
| if strVal, ok := v.(string); ok { |
| if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { |
| return intVal |
| } |
| } |
| |
| // number values are represented as float64 |
| if floatVal, ok := v.(float64); ok { |
| intVal := int(floatVal) |
| return intVal |
| } |
| |
| return v // let terraform core handle it otherwise |
| } |
| |
| func flattenLookerInstanceCustomDomain(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| if v == nil { |
| return nil |
| } |
| original := v.(map[string]interface{}) |
| if len(original) == 0 { |
| return nil |
| } |
| transformed := make(map[string]interface{}) |
| transformed["domain"] = |
| flattenLookerInstanceCustomDomainDomain(original["domain"], d, config) |
| transformed["state"] = |
| flattenLookerInstanceCustomDomainState(original["state"], d, config) |
| return []interface{}{transformed} |
| } |
| func flattenLookerInstanceCustomDomainDomain(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func flattenLookerInstanceCustomDomainState(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { |
| return v |
| } |
| |
| func expandLookerInstanceAdminSettings(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| l := v.([]interface{}) |
| if len(l) == 0 || l[0] == nil { |
| return nil, nil |
| } |
| raw := l[0] |
| original := raw.(map[string]interface{}) |
| transformed := make(map[string]interface{}) |
| |
| transformedAllowedEmailDomains, err := expandLookerInstanceAdminSettingsAllowedEmailDomains(original["allowed_email_domains"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedAllowedEmailDomains); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["allowedEmailDomains"] = transformedAllowedEmailDomains |
| } |
| |
| return transformed, nil |
| } |
| |
| func expandLookerInstanceAdminSettingsAllowedEmailDomains(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandLookerInstanceConsumerNetwork(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandLookerInstanceDenyMaintenancePeriod(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| l := v.([]interface{}) |
| if len(l) == 0 || l[0] == nil { |
| return nil, nil |
| } |
| raw := l[0] |
| original := raw.(map[string]interface{}) |
| transformed := make(map[string]interface{}) |
| |
| transformedStartDate, err := expandLookerInstanceDenyMaintenancePeriodStartDate(original["start_date"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedStartDate); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["startDate"] = transformedStartDate |
| } |
| |
| transformedEndDate, err := expandLookerInstanceDenyMaintenancePeriodEndDate(original["end_date"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedEndDate); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["endDate"] = transformedEndDate |
| } |
| |
| transformedTime, err := expandLookerInstanceDenyMaintenancePeriodTime(original["time"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedTime); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["time"] = transformedTime |
| } |
| |
| return transformed, nil |
| } |
| |
| func expandLookerInstanceDenyMaintenancePeriodStartDate(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| l := v.([]interface{}) |
| if len(l) == 0 || l[0] == nil { |
| return nil, nil |
| } |
| raw := l[0] |
| original := raw.(map[string]interface{}) |
| transformed := make(map[string]interface{}) |
| |
| transformedYear, err := expandLookerInstanceDenyMaintenancePeriodStartDateYear(original["year"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedYear); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["year"] = transformedYear |
| } |
| |
| transformedMonth, err := expandLookerInstanceDenyMaintenancePeriodStartDateMonth(original["month"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedMonth); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["month"] = transformedMonth |
| } |
| |
| transformedDay, err := expandLookerInstanceDenyMaintenancePeriodStartDateDay(original["day"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedDay); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["day"] = transformedDay |
| } |
| |
| return transformed, nil |
| } |
| |
| func expandLookerInstanceDenyMaintenancePeriodStartDateYear(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandLookerInstanceDenyMaintenancePeriodStartDateMonth(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandLookerInstanceDenyMaintenancePeriodStartDateDay(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandLookerInstanceDenyMaintenancePeriodEndDate(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| l := v.([]interface{}) |
| if len(l) == 0 || l[0] == nil { |
| return nil, nil |
| } |
| raw := l[0] |
| original := raw.(map[string]interface{}) |
| transformed := make(map[string]interface{}) |
| |
| transformedYear, err := expandLookerInstanceDenyMaintenancePeriodEndDateYear(original["year"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedYear); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["year"] = transformedYear |
| } |
| |
| transformedMonth, err := expandLookerInstanceDenyMaintenancePeriodEndDateMonth(original["month"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedMonth); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["month"] = transformedMonth |
| } |
| |
| transformedDay, err := expandLookerInstanceDenyMaintenancePeriodEndDateDay(original["day"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedDay); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["day"] = transformedDay |
| } |
| |
| return transformed, nil |
| } |
| |
| func expandLookerInstanceDenyMaintenancePeriodEndDateYear(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandLookerInstanceDenyMaintenancePeriodEndDateMonth(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandLookerInstanceDenyMaintenancePeriodEndDateDay(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandLookerInstanceDenyMaintenancePeriodTime(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| l := v.([]interface{}) |
| if len(l) == 0 || l[0] == nil { |
| return nil, nil |
| } |
| raw := l[0] |
| original := raw.(map[string]interface{}) |
| transformed := make(map[string]interface{}) |
| |
| transformedHours, err := expandLookerInstanceDenyMaintenancePeriodTimeHours(original["hours"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedHours); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["hours"] = transformedHours |
| } |
| |
| transformedMinutes, err := expandLookerInstanceDenyMaintenancePeriodTimeMinutes(original["minutes"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedMinutes); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["minutes"] = transformedMinutes |
| } |
| |
| transformedSeconds, err := expandLookerInstanceDenyMaintenancePeriodTimeSeconds(original["seconds"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedSeconds); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["seconds"] = transformedSeconds |
| } |
| |
| transformedNanos, err := expandLookerInstanceDenyMaintenancePeriodTimeNanos(original["nanos"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedNanos); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["nanos"] = transformedNanos |
| } |
| |
| return transformed, nil |
| } |
| |
| func expandLookerInstanceDenyMaintenancePeriodTimeHours(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandLookerInstanceDenyMaintenancePeriodTimeMinutes(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandLookerInstanceDenyMaintenancePeriodTimeSeconds(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandLookerInstanceDenyMaintenancePeriodTimeNanos(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandLookerInstanceEncryptionConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| l := v.([]interface{}) |
| if len(l) == 0 || l[0] == nil { |
| return nil, nil |
| } |
| raw := l[0] |
| original := raw.(map[string]interface{}) |
| transformed := make(map[string]interface{}) |
| |
| transformedKmsKeyName, err := expandLookerInstanceEncryptionConfigKmsKeyName(original["kms_key_name"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedKmsKeyName); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["kmsKeyName"] = transformedKmsKeyName |
| } |
| |
| transformedKmsKeyState, err := expandLookerInstanceEncryptionConfigKmsKeyState(original["kms_key_state"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedKmsKeyState); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["kmsKeyState"] = transformedKmsKeyState |
| } |
| |
| transformedKmsKeyNameVersion, err := expandLookerInstanceEncryptionConfigKmsKeyNameVersion(original["kms_key_name_version"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedKmsKeyNameVersion); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["kmsKeyNameVersion"] = transformedKmsKeyNameVersion |
| } |
| |
| return transformed, nil |
| } |
| |
| func expandLookerInstanceEncryptionConfigKmsKeyName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandLookerInstanceEncryptionConfigKmsKeyState(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandLookerInstanceEncryptionConfigKmsKeyNameVersion(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandLookerInstanceMaintenanceWindow(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| l := v.([]interface{}) |
| if len(l) == 0 || l[0] == nil { |
| return nil, nil |
| } |
| raw := l[0] |
| original := raw.(map[string]interface{}) |
| transformed := make(map[string]interface{}) |
| |
| transformedDayOfWeek, err := expandLookerInstanceMaintenanceWindowDayOfWeek(original["day_of_week"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedDayOfWeek); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["dayOfWeek"] = transformedDayOfWeek |
| } |
| |
| transformedStartTime, err := expandLookerInstanceMaintenanceWindowStartTime(original["start_time"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedStartTime); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["startTime"] = transformedStartTime |
| } |
| |
| return transformed, nil |
| } |
| |
| func expandLookerInstanceMaintenanceWindowDayOfWeek(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandLookerInstanceMaintenanceWindowStartTime(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| l := v.([]interface{}) |
| if len(l) == 0 || l[0] == nil { |
| return nil, nil |
| } |
| raw := l[0] |
| original := raw.(map[string]interface{}) |
| transformed := make(map[string]interface{}) |
| |
| transformedHours, err := expandLookerInstanceMaintenanceWindowStartTimeHours(original["hours"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedHours); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["hours"] = transformedHours |
| } |
| |
| transformedMinutes, err := expandLookerInstanceMaintenanceWindowStartTimeMinutes(original["minutes"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedMinutes); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["minutes"] = transformedMinutes |
| } |
| |
| transformedSeconds, err := expandLookerInstanceMaintenanceWindowStartTimeSeconds(original["seconds"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedSeconds); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["seconds"] = transformedSeconds |
| } |
| |
| transformedNanos, err := expandLookerInstanceMaintenanceWindowStartTimeNanos(original["nanos"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedNanos); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["nanos"] = transformedNanos |
| } |
| |
| return transformed, nil |
| } |
| |
| func expandLookerInstanceMaintenanceWindowStartTimeHours(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandLookerInstanceMaintenanceWindowStartTimeMinutes(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandLookerInstanceMaintenanceWindowStartTimeSeconds(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandLookerInstanceMaintenanceWindowStartTimeNanos(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandLookerInstanceOauthConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| l := v.([]interface{}) |
| if len(l) == 0 || l[0] == nil { |
| return nil, nil |
| } |
| raw := l[0] |
| original := raw.(map[string]interface{}) |
| transformed := make(map[string]interface{}) |
| |
| transformedClientId, err := expandLookerInstanceOauthConfigClientId(original["client_id"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedClientId); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["clientId"] = transformedClientId |
| } |
| |
| transformedClientSecret, err := expandLookerInstanceOauthConfigClientSecret(original["client_secret"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedClientSecret); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["clientSecret"] = transformedClientSecret |
| } |
| |
| return transformed, nil |
| } |
| |
| func expandLookerInstanceOauthConfigClientId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandLookerInstanceOauthConfigClientSecret(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandLookerInstancePlatformEdition(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandLookerInstancePrivateIpEnabled(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandLookerInstancePublicIpEnabled(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandLookerInstanceReservedRange(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandLookerInstanceUserMetadata(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| l := v.([]interface{}) |
| if len(l) == 0 || l[0] == nil { |
| return nil, nil |
| } |
| raw := l[0] |
| original := raw.(map[string]interface{}) |
| transformed := make(map[string]interface{}) |
| |
| transformedAdditionalViewerUserCount, err := expandLookerInstanceUserMetadataAdditionalViewerUserCount(original["additional_viewer_user_count"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedAdditionalViewerUserCount); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["additionalViewerUserCount"] = transformedAdditionalViewerUserCount |
| } |
| |
| transformedAdditionalStandardUserCount, err := expandLookerInstanceUserMetadataAdditionalStandardUserCount(original["additional_standard_user_count"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedAdditionalStandardUserCount); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["additionalStandardUserCount"] = transformedAdditionalStandardUserCount |
| } |
| |
| transformedAdditionalDeveloperUserCount, err := expandLookerInstanceUserMetadataAdditionalDeveloperUserCount(original["additional_developer_user_count"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedAdditionalDeveloperUserCount); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["additionalDeveloperUserCount"] = transformedAdditionalDeveloperUserCount |
| } |
| |
| return transformed, nil |
| } |
| |
| func expandLookerInstanceUserMetadataAdditionalViewerUserCount(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandLookerInstanceUserMetadataAdditionalStandardUserCount(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandLookerInstanceUserMetadataAdditionalDeveloperUserCount(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandLookerInstanceCustomDomain(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| l := v.([]interface{}) |
| if len(l) == 0 || l[0] == nil { |
| return nil, nil |
| } |
| raw := l[0] |
| original := raw.(map[string]interface{}) |
| transformed := make(map[string]interface{}) |
| |
| transformedDomain, err := expandLookerInstanceCustomDomainDomain(original["domain"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedDomain); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["domain"] = transformedDomain |
| } |
| |
| transformedState, err := expandLookerInstanceCustomDomainState(original["state"], d, config) |
| if err != nil { |
| return nil, err |
| } else if val := reflect.ValueOf(transformedState); val.IsValid() && !tpgresource.IsEmptyValue(val) { |
| transformed["state"] = transformedState |
| } |
| |
| return transformed, nil |
| } |
| |
| func expandLookerInstanceCustomDomainDomain(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |
| |
| func expandLookerInstanceCustomDomainState(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| return v, nil |
| } |