blob: 231ae1b4ea6b3e560f65e776a21b3a6fda937b0c [file] [log] [blame] [edit]
// 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 netapp
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-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 ResourceNetappVolume() *schema.Resource {
return &schema.Resource{
Create: resourceNetappVolumeCreate,
Read: resourceNetappVolumeRead,
Update: resourceNetappVolumeUpdate,
Delete: resourceNetappVolumeDelete,
Importer: &schema.ResourceImporter{
State: resourceNetappVolumeImport,
},
Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(20 * time.Minute),
Update: schema.DefaultTimeout(20 * time.Minute),
Delete: schema.DefaultTimeout(20 * time.Minute),
},
CustomizeDiff: customdiff.All(
tpgresource.SetLabelsDiff,
tpgresource.DefaultProviderProject,
),
Schema: map[string]*schema.Schema{
"capacity_gib": {
Type: schema.TypeString,
Required: true,
Description: `Capacity of the volume (in GiB).`,
},
"location": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: `Name of the pool location. Usually a region name, expect for some STANDARD service level pools which require a zone name.`,
},
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: `The name of the volume. Needs to be unique per location.`,
},
"protocols": {
Type: schema.TypeList,
Required: true,
ForceNew: true,
Description: `The protocol of the volume. Allowed combinations are '['NFSV3']', '['NFSV4']', '['SMB']', '['NFSV3', 'NFSV4']', '['SMB', 'NFSV3']' and '['SMB', 'NFSV4']'. Possible values: ["NFSV3", "NFSV4", "SMB"]`,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: verify.ValidateEnum([]string{"NFSV3", "NFSV4", "SMB"}),
},
},
"share_name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: `Share name (SMB) or export path (NFS) of the volume. Needs to be unique per location.`,
},
"storage_pool": {
Type: schema.TypeString,
Required: true,
Description: `Name of the storage pool to create the volume in. Pool needs enough spare capacity to accomodate the volume.`,
},
"description": {
Type: schema.TypeString,
Optional: true,
Description: `An optional description of this resource.`,
},
"export_policy": {
Type: schema.TypeList,
Optional: true,
Description: `Export policy of the volume for NFSV3 and/or NFSV4.1 access.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"rules": {
Type: schema.TypeList,
Required: true,
Description: `Export rules (up to 5) control NFS volume access.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"access_type": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: verify.ValidateEnum([]string{"READ_ONLY", "READ_WRITE", "READ_NONE", ""}),
Description: `Defines the access type for clients matching the 'allowedClients' specification. Possible values: ["READ_ONLY", "READ_WRITE", "READ_NONE"]`,
},
"allowed_clients": {
Type: schema.TypeString,
Optional: true,
Description: `Defines the client ingress specification (allowed clients) as a comma seperated list with IPv4 CIDRs or IPv4 host addresses.`,
},
"has_root_access": {
Type: schema.TypeString,
Optional: true,
Description: `If enabled, the root user (UID = 0) of the specified clients doesn't get mapped to nobody (UID = 65534). This is also known as no_root_squash.`,
},
"kerberos5_read_only": {
Type: schema.TypeBool,
Optional: true,
Description: `If enabled (true) the rule defines a read only access for clients matching the 'allowedClients' specification. It enables nfs clients to mount using 'authentication' kerberos security mode.`,
},
"kerberos5_read_write": {
Type: schema.TypeBool,
Optional: true,
Description: `If enabled (true) the rule defines read and write access for clients matching the 'allowedClients' specification. It enables nfs clients to mount using 'authentication' kerberos security mode. The 'kerberos5ReadOnly' value is ignored if this is enabled.`,
},
"kerberos5i_read_only": {
Type: schema.TypeBool,
Optional: true,
Description: `If enabled (true) the rule defines a read only access for clients matching the 'allowedClients' specification. It enables nfs clients to mount using 'integrity' kerberos security mode.`,
},
"kerberos5i_read_write": {
Type: schema.TypeBool,
Optional: true,
Description: `If enabled (true) the rule defines read and write access for clients matching the 'allowedClients' specification. It enables nfs clients to mount using 'integrity' kerberos security mode. The 'kerberos5iReadOnly' value is ignored if this is enabled.`,
},
"kerberos5p_read_only": {
Type: schema.TypeBool,
Optional: true,
Description: `If enabled (true) the rule defines a read only access for clients matching the 'allowedClients' specification. It enables nfs clients to mount using 'privacy' kerberos security mode.`,
},
"kerberos5p_read_write": {
Type: schema.TypeBool,
Optional: true,
Description: `If enabled (true) the rule defines read and write access for clients matching the 'allowedClients' specification. It enables nfs clients to mount using 'privacy' kerberos security mode. The 'kerberos5pReadOnly' value is ignored if this is enabled.`,
},
"nfsv3": {
Type: schema.TypeBool,
Optional: true,
Description: `Enable to apply the export rule to NFSV3 clients.`,
},
"nfsv4": {
Type: schema.TypeBool,
Optional: true,
Description: `Enable to apply the export rule to NFSV4.1 clients.`,
},
},
},
},
},
},
},
"kerberos_enabled": {
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
Description: `Flag indicating if the volume is a kerberos volume or not, export policy rules control kerberos security modes (krb5, krb5i, krb5p).`,
Default: false,
},
"labels": {
Type: schema.TypeMap,
Optional: true,
Description: `Labels as key value pairs. Example: '{ "owner": "Bob", "department": "finance", "purpose": "testing" }'.
**Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
Please refer to the field 'effective_labels' for all of the labels present on the resource.`,
Elem: &schema.Schema{Type: schema.TypeString},
},
"restore_parameters": {
Type: schema.TypeList,
Optional: true,
ForceNew: true,
Description: `Used to create this volume from a snapshot (= cloning) or an backup.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"source_backup": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Description: `Full name of the snapshot to use for creating this volume.
'source_snapshot' and 'source_backup' cannot be used simultaneously.
Format: 'projects/{{project}}/locations/{{location}}/backupVaults/{{backupVaultId}}/backups/{{backup}}'.`,
ExactlyOneOf: []string{"restore_parameters.0.source_backup", "restore_parameters.0.source_snapshot"},
},
"source_snapshot": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Description: `Full name of the snapshot to use for creating this volume.
'source_snapshot' and 'source_backup' cannot be used simultaneously.
Format: 'projects/{{project}}/locations/{{location}}/volumes/{{volume}}/snapshots/{{snapshot}}'.`,
ExactlyOneOf: []string{"restore_parameters.0.source_backup", "restore_parameters.0.source_snapshot"},
},
},
},
},
"restricted_actions": {
Type: schema.TypeList,
Optional: true,
Description: `List of actions that are restricted on this volume. Possible values: ["DELETE"]`,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: verify.ValidateEnum([]string{"DELETE"}),
},
},
"security_style": {
Type: schema.TypeString,
Computed: true,
Optional: true,
ForceNew: true,
ValidateFunc: verify.ValidateEnum([]string{"NTFS", "UNIX", ""}),
Description: `Security Style of the Volume. Use UNIX to use UNIX or NFSV4 ACLs for file permissions.
Use NTFS to use NTFS ACLs for file permissions. Can only be set for volumes which use SMB together with NFS as protocol. Possible values: ["NTFS", "UNIX"]`,
},
"smb_settings": {
Type: schema.TypeList,
Optional: true,
Description: `Settings for volumes with SMB access. Possible values: ["ENCRYPT_DATA", "BROWSABLE", "CHANGE_NOTIFY", "NON_BROWSABLE", "OPLOCKS", "SHOW_SNAPSHOT", "SHOW_PREVIOUS_VERSIONS", "ACCESS_BASED_ENUMERATION", "CONTINUOUSLY_AVAILABLE"]`,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: verify.ValidateEnum([]string{"ENCRYPT_DATA", "BROWSABLE", "CHANGE_NOTIFY", "NON_BROWSABLE", "OPLOCKS", "SHOW_SNAPSHOT", "SHOW_PREVIOUS_VERSIONS", "ACCESS_BASED_ENUMERATION", "CONTINUOUSLY_AVAILABLE"}),
},
},
"snapshot_directory": {
Type: schema.TypeBool,
Optional: true,
Description: `If enabled, a NFS volume will contain a read-only .snapshot directory which provides access to each of the volume's snapshots. Will enable "Previous Versions" support for SMB.`,
},
"snapshot_policy": {
Type: schema.TypeList,
Optional: true,
Description: `Snapshot policy defines the schedule for automatic snapshot creation.
To disable automatic snapshot creation you have to remove the whole snapshot_policy block.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"daily_schedule": {
Type: schema.TypeList,
Optional: true,
Description: `Daily schedule policy.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"snapshots_to_keep": {
Type: schema.TypeInt,
Required: true,
Description: `The maximum number of snapshots to keep for the daily schedule.`,
},
"hour": {
Type: schema.TypeInt,
Optional: true,
Description: `Set the hour to create the snapshot (0-23), defaults to midnight (0).`,
Default: 0,
},
"minute": {
Type: schema.TypeInt,
Optional: true,
Description: `Set the minute of the hour to create the snapshot (0-59), defaults to the top of the hour (0).`,
Default: 0,
},
},
},
},
"enabled": {
Type: schema.TypeBool,
Optional: true,
Description: `Enables automated snapshot creation according to defined schedule. Default is false.
To disable automatic snapshot creation you have to remove the whole snapshot_policy block.`,
Default: false,
},
"hourly_schedule": {
Type: schema.TypeList,
Optional: true,
Description: `Hourly schedule policy.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"snapshots_to_keep": {
Type: schema.TypeInt,
Required: true,
Description: `The maximum number of snapshots to keep for the hourly schedule.`,
},
"minute": {
Type: schema.TypeInt,
Optional: true,
Description: `Set the minute of the hour to create the snapshot (0-59), defaults to the top of the hour (0).`,
Default: 0,
},
},
},
},
"monthly_schedule": {
Type: schema.TypeList,
Optional: true,
Description: `Monthly schedule policy.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"snapshots_to_keep": {
Type: schema.TypeInt,
Required: true,
Description: `The maximum number of snapshots to keep for the monthly schedule`,
},
"days_of_month": {
Type: schema.TypeString,
Optional: true,
Description: `Set the day or days of the month to make a snapshot (1-31). Accepts a comma separated number of days. Defaults to '1'.`,
Default: "1",
},
"hour": {
Type: schema.TypeInt,
Optional: true,
Description: `Set the hour to create the snapshot (0-23), defaults to midnight (0).`,
Default: 0,
},
"minute": {
Type: schema.TypeInt,
Optional: true,
Description: `Set the minute of the hour to create the snapshot (0-59), defaults to the top of the hour (0).`,
Default: 0,
},
},
},
},
"weekly_schedule": {
Type: schema.TypeList,
Optional: true,
Description: `Weekly schedule policy.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"snapshots_to_keep": {
Type: schema.TypeInt,
Required: true,
Description: `The maximum number of snapshots to keep for the weekly schedule.`,
},
"day": {
Type: schema.TypeString,
Optional: true,
Description: `Set the day or days of the week to make a snapshot. Accepts a comma separated days of the week. Defaults to 'Sunday'.`,
Default: "Sunday",
},
"hour": {
Type: schema.TypeInt,
Optional: true,
Description: `Set the hour to create the snapshot (0-23), defaults to midnight (0).`,
Default: 0,
},
"minute": {
Type: schema.TypeInt,
Optional: true,
Description: `Set the minute of the hour to create the snapshot (0-59), defaults to the top of the hour (0).`,
Default: 0,
},
},
},
},
},
},
},
"unix_permissions": {
Type: schema.TypeString,
Computed: true,
Optional: true,
Description: `Unix permission the mount point will be created with. Default is 0770. Applicable for UNIX security style volumes only.`,
},
"active_directory": {
Type: schema.TypeString,
Computed: true,
Description: `Reports the resource name of the Active Directory policy being used. Inherited from storage pool.`,
},
"create_time": {
Type: schema.TypeString,
Computed: true,
Description: `Create time of the volume. A timestamp in RFC3339 UTC "Zulu" format. Examples: "2023-06-22T09:13:01.617Z".`,
},
"effective_labels": {
Type: schema.TypeMap,
Computed: true,
Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`,
Elem: &schema.Schema{Type: schema.TypeString},
},
"encryption_type": {
Type: schema.TypeString,
Computed: true,
Description: `Reports the data-at-rest encryption type of the volume. Inherited from storage pool.`,
},
"has_replication": {
Type: schema.TypeBool,
Computed: true,
Description: `Indicates whether the volume is part of a volume replication relationship.`,
},
"kms_config": {
Type: schema.TypeString,
Computed: true,
Description: `Reports the CMEK policy resurce name being used for volume encryption. Inherited from storage pool.`,
},
"ldap_enabled": {
Type: schema.TypeBool,
Computed: true,
Description: `Flag indicating if the volume is NFS LDAP enabled or not. Inherited from storage pool.`,
},
"mount_options": {
Type: schema.TypeList,
Computed: true,
Description: `Reports mount instructions for this volume.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"export": {
Type: schema.TypeString,
Computed: true,
Description: `Export path of the volume.`,
},
"export_full": {
Type: schema.TypeString,
Computed: true,
Description: `Full export path of the volume.
Format for NFS volumes: '<export_ip>:/<shareName>'
Format for SMB volumes: '\\\\netbios_prefix-four_random_hex_letters.domain_name\\shareName'`,
},
"instructions": {
Type: schema.TypeString,
Computed: true,
Description: `Human-readable mount instructions.`,
},
"protocol": {
Type: schema.TypeString,
Computed: true,
Description: `Protocol to mount with.`,
},
},
},
},
"network": {
Type: schema.TypeString,
Computed: true,
Description: `VPC network name with format: 'projects/{{project}}/global/networks/{{network}}'. Inherited from storage pool.`,
},
"psa_range": {
Type: schema.TypeString,
Computed: true,
Description: `Name of the Private Service Access allocated range. Inherited from storage pool.`,
},
"service_level": {
Type: schema.TypeString,
Computed: true,
Description: `Service level of the volume. Inherited from storage pool.`,
},
"state": {
Type: schema.TypeString,
Computed: true,
Description: `State of the volume.`,
},
"state_details": {
Type: schema.TypeString,
Computed: true,
Description: `State details of the volume.`,
},
"terraform_labels": {
Type: schema.TypeMap,
Computed: true,
Description: `The combination of labels configured directly on the resource
and default labels configured on the provider.`,
Elem: &schema.Schema{Type: schema.TypeString},
},
"used_gib": {
Type: schema.TypeString,
Computed: true,
Description: `Used capacity of the volume (in GiB). This is computed periodically and it does not represent the realtime usage.`,
},
"deletion_policy": {
Type: schema.TypeString,
Optional: true,
Default: "DEFAULT",
Description: `Policy to determine if the volume should be deleted forcefully.
Volumes may have nested snapshot resources. Deleting such a volume will fail.
Setting this parameter to FORCE will delete volumes including nested snapshots.`,
},
"project": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
},
UseJSONNumber: true,
}
}
func resourceNetappVolumeCreate(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{})
shareNameProp, err := expandNetappVolumeShareName(d.Get("share_name"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("share_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(shareNameProp)) && (ok || !reflect.DeepEqual(v, shareNameProp)) {
obj["shareName"] = shareNameProp
}
storagePoolProp, err := expandNetappVolumeStoragePool(d.Get("storage_pool"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("storage_pool"); !tpgresource.IsEmptyValue(reflect.ValueOf(storagePoolProp)) && (ok || !reflect.DeepEqual(v, storagePoolProp)) {
obj["storagePool"] = storagePoolProp
}
capacityGibProp, err := expandNetappVolumeCapacityGib(d.Get("capacity_gib"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("capacity_gib"); !tpgresource.IsEmptyValue(reflect.ValueOf(capacityGibProp)) && (ok || !reflect.DeepEqual(v, capacityGibProp)) {
obj["capacityGib"] = capacityGibProp
}
exportPolicyProp, err := expandNetappVolumeExportPolicy(d.Get("export_policy"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("export_policy"); !tpgresource.IsEmptyValue(reflect.ValueOf(exportPolicyProp)) && (ok || !reflect.DeepEqual(v, exportPolicyProp)) {
obj["exportPolicy"] = exportPolicyProp
}
protocolsProp, err := expandNetappVolumeProtocols(d.Get("protocols"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("protocols"); !tpgresource.IsEmptyValue(reflect.ValueOf(protocolsProp)) && (ok || !reflect.DeepEqual(v, protocolsProp)) {
obj["protocols"] = protocolsProp
}
smbSettingsProp, err := expandNetappVolumeSmbSettings(d.Get("smb_settings"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("smb_settings"); !tpgresource.IsEmptyValue(reflect.ValueOf(smbSettingsProp)) && (ok || !reflect.DeepEqual(v, smbSettingsProp)) {
obj["smbSettings"] = smbSettingsProp
}
unixPermissionsProp, err := expandNetappVolumeUnixPermissions(d.Get("unix_permissions"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("unix_permissions"); !tpgresource.IsEmptyValue(reflect.ValueOf(unixPermissionsProp)) && (ok || !reflect.DeepEqual(v, unixPermissionsProp)) {
obj["unixPermissions"] = unixPermissionsProp
}
descriptionProp, err := expandNetappVolumeDescription(d.Get("description"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) {
obj["description"] = descriptionProp
}
snapshotDirectoryProp, err := expandNetappVolumeSnapshotDirectory(d.Get("snapshot_directory"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("snapshot_directory"); !tpgresource.IsEmptyValue(reflect.ValueOf(snapshotDirectoryProp)) && (ok || !reflect.DeepEqual(v, snapshotDirectoryProp)) {
obj["snapshotDirectory"] = snapshotDirectoryProp
}
securityStyleProp, err := expandNetappVolumeSecurityStyle(d.Get("security_style"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("security_style"); !tpgresource.IsEmptyValue(reflect.ValueOf(securityStyleProp)) && (ok || !reflect.DeepEqual(v, securityStyleProp)) {
obj["securityStyle"] = securityStyleProp
}
kerberosEnabledProp, err := expandNetappVolumeKerberosEnabled(d.Get("kerberos_enabled"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("kerberos_enabled"); !tpgresource.IsEmptyValue(reflect.ValueOf(kerberosEnabledProp)) && (ok || !reflect.DeepEqual(v, kerberosEnabledProp)) {
obj["kerberosEnabled"] = kerberosEnabledProp
}
restoreParametersProp, err := expandNetappVolumeRestoreParameters(d.Get("restore_parameters"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("restore_parameters"); !tpgresource.IsEmptyValue(reflect.ValueOf(restoreParametersProp)) && (ok || !reflect.DeepEqual(v, restoreParametersProp)) {
obj["restoreParameters"] = restoreParametersProp
}
restrictedActionsProp, err := expandNetappVolumeRestrictedActions(d.Get("restricted_actions"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("restricted_actions"); !tpgresource.IsEmptyValue(reflect.ValueOf(restrictedActionsProp)) && (ok || !reflect.DeepEqual(v, restrictedActionsProp)) {
obj["restrictedActions"] = restrictedActionsProp
}
snapshotPolicyProp, err := expandNetappVolumeSnapshotPolicy(d.Get("snapshot_policy"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("snapshot_policy"); !tpgresource.IsEmptyValue(reflect.ValueOf(snapshotPolicyProp)) && (ok || !reflect.DeepEqual(v, snapshotPolicyProp)) {
obj["snapshotPolicy"] = snapshotPolicyProp
}
labelsProp, err := expandNetappVolumeEffectiveLabels(d.Get("effective_labels"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) {
obj["labels"] = labelsProp
}
url, err := tpgresource.ReplaceVars(d, config, "{{NetappBasePath}}projects/{{project}}/locations/{{location}}/volumes?volumeId={{name}}")
if err != nil {
return err
}
log.Printf("[DEBUG] Creating new Volume: %#v", obj)
billingProject := ""
project, err := tpgresource.GetProject(d, config)
if err != nil {
return fmt.Errorf("Error fetching project for Volume: %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),
})
if err != nil {
return fmt.Errorf("Error creating Volume: %s", err)
}
// Store the ID now
id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/volumes/{{name}}")
if err != nil {
return fmt.Errorf("Error constructing id: %s", err)
}
d.SetId(id)
err = NetappOperationWaitTime(
config, res, project, "Creating Volume", userAgent,
d.Timeout(schema.TimeoutCreate))
if err != nil {
// The resource didn't actually create
d.SetId("")
return fmt.Errorf("Error waiting to create Volume: %s", err)
}
log.Printf("[DEBUG] Finished creating Volume %q: %#v", d.Id(), res)
return resourceNetappVolumeRead(d, meta)
}
func resourceNetappVolumeRead(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, "{{NetappBasePath}}projects/{{project}}/locations/{{location}}/volumes/{{name}}")
if err != nil {
return err
}
billingProject := ""
project, err := tpgresource.GetProject(d, config)
if err != nil {
return fmt.Errorf("Error fetching project for Volume: %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,
})
if err != nil {
return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NetappVolume %q", d.Id()))
}
// Explicitly set virtual fields to default values if unset
if _, ok := d.GetOkExists("deletion_policy"); !ok {
if err := d.Set("deletion_policy", "DEFAULT"); err != nil {
return fmt.Errorf("Error setting deletion_policy: %s", err)
}
}
if err := d.Set("project", project); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("state", flattenNetappVolumeState(res["state"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("state_details", flattenNetappVolumeStateDetails(res["stateDetails"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("create_time", flattenNetappVolumeCreateTime(res["createTime"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("share_name", flattenNetappVolumeShareName(res["shareName"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("psa_range", flattenNetappVolumePsaRange(res["psaRange"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("storage_pool", flattenNetappVolumeStoragePool(res["storagePool"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("network", flattenNetappVolumeNetwork(res["network"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("service_level", flattenNetappVolumeServiceLevel(res["serviceLevel"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("capacity_gib", flattenNetappVolumeCapacityGib(res["capacityGib"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("export_policy", flattenNetappVolumeExportPolicy(res["exportPolicy"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("protocols", flattenNetappVolumeProtocols(res["protocols"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("smb_settings", flattenNetappVolumeSmbSettings(res["smbSettings"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("unix_permissions", flattenNetappVolumeUnixPermissions(res["unixPermissions"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("labels", flattenNetappVolumeLabels(res["labels"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("description", flattenNetappVolumeDescription(res["description"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("snapshot_directory", flattenNetappVolumeSnapshotDirectory(res["snapshotDirectory"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("used_gib", flattenNetappVolumeUsedGib(res["usedGib"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("security_style", flattenNetappVolumeSecurityStyle(res["securityStyle"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("kerberos_enabled", flattenNetappVolumeKerberosEnabled(res["kerberosEnabled"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("ldap_enabled", flattenNetappVolumeLdapEnabled(res["ldapEnabled"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("active_directory", flattenNetappVolumeActiveDirectory(res["activeDirectory"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("kms_config", flattenNetappVolumeKmsConfig(res["kmsConfig"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("encryption_type", flattenNetappVolumeEncryptionType(res["encryptionType"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("has_replication", flattenNetappVolumeHasReplication(res["hasReplication"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("restricted_actions", flattenNetappVolumeRestrictedActions(res["restrictedActions"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("mount_options", flattenNetappVolumeMountOptions(res["mountOptions"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("snapshot_policy", flattenNetappVolumeSnapshotPolicy(res["snapshotPolicy"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("terraform_labels", flattenNetappVolumeTerraformLabels(res["labels"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("effective_labels", flattenNetappVolumeEffectiveLabels(res["labels"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
return nil
}
func resourceNetappVolumeUpdate(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 Volume: %s", err)
}
billingProject = project
obj := make(map[string]interface{})
storagePoolProp, err := expandNetappVolumeStoragePool(d.Get("storage_pool"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("storage_pool"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, storagePoolProp)) {
obj["storagePool"] = storagePoolProp
}
capacityGibProp, err := expandNetappVolumeCapacityGib(d.Get("capacity_gib"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("capacity_gib"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, capacityGibProp)) {
obj["capacityGib"] = capacityGibProp
}
exportPolicyProp, err := expandNetappVolumeExportPolicy(d.Get("export_policy"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("export_policy"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, exportPolicyProp)) {
obj["exportPolicy"] = exportPolicyProp
}
smbSettingsProp, err := expandNetappVolumeSmbSettings(d.Get("smb_settings"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("smb_settings"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, smbSettingsProp)) {
obj["smbSettings"] = smbSettingsProp
}
unixPermissionsProp, err := expandNetappVolumeUnixPermissions(d.Get("unix_permissions"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("unix_permissions"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, unixPermissionsProp)) {
obj["unixPermissions"] = unixPermissionsProp
}
descriptionProp, err := expandNetappVolumeDescription(d.Get("description"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, descriptionProp)) {
obj["description"] = descriptionProp
}
snapshotDirectoryProp, err := expandNetappVolumeSnapshotDirectory(d.Get("snapshot_directory"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("snapshot_directory"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, snapshotDirectoryProp)) {
obj["snapshotDirectory"] = snapshotDirectoryProp
}
restrictedActionsProp, err := expandNetappVolumeRestrictedActions(d.Get("restricted_actions"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("restricted_actions"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, restrictedActionsProp)) {
obj["restrictedActions"] = restrictedActionsProp
}
snapshotPolicyProp, err := expandNetappVolumeSnapshotPolicy(d.Get("snapshot_policy"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("snapshot_policy"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, snapshotPolicyProp)) {
obj["snapshotPolicy"] = snapshotPolicyProp
}
labelsProp, err := expandNetappVolumeEffectiveLabels(d.Get("effective_labels"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, labelsProp)) {
obj["labels"] = labelsProp
}
url, err := tpgresource.ReplaceVars(d, config, "{{NetappBasePath}}projects/{{project}}/locations/{{location}}/volumes/{{name}}")
if err != nil {
return err
}
log.Printf("[DEBUG] Updating Volume %q: %#v", d.Id(), obj)
updateMask := []string{}
if d.HasChange("storage_pool") {
updateMask = append(updateMask, "storagePool")
}
if d.HasChange("capacity_gib") {
updateMask = append(updateMask, "capacityGib")
}
if d.HasChange("export_policy") {
updateMask = append(updateMask, "exportPolicy")
}
if d.HasChange("smb_settings") {
updateMask = append(updateMask, "smbSettings")
}
if d.HasChange("unix_permissions") {
updateMask = append(updateMask, "unixPermissions")
}
if d.HasChange("description") {
updateMask = append(updateMask, "description")
}
if d.HasChange("snapshot_directory") {
updateMask = append(updateMask, "snapshotDirectory")
}
if d.HasChange("restricted_actions") {
updateMask = append(updateMask, "restrictedActions")
}
if d.HasChange("snapshot_policy") {
updateMask = append(updateMask, "snapshotPolicy")
}
if d.HasChange("effective_labels") {
updateMask = append(updateMask, "labels")
}
// 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),
})
if err != nil {
return fmt.Errorf("Error updating Volume %q: %s", d.Id(), err)
} else {
log.Printf("[DEBUG] Finished updating Volume %q: %#v", d.Id(), res)
}
err = NetappOperationWaitTime(
config, res, project, "Updating Volume", userAgent,
d.Timeout(schema.TimeoutUpdate))
if err != nil {
return err
}
}
return resourceNetappVolumeRead(d, meta)
}
func resourceNetappVolumeDelete(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 Volume: %s", err)
}
billingProject = project
url, err := tpgresource.ReplaceVars(d, config, "{{NetappBasePath}}projects/{{project}}/locations/{{location}}/volumes/{{name}}")
if err != nil {
return err
}
var obj map[string]interface{}
// Delete volume even when nested snapshots do exist
if deletionPolicy := d.Get("deletion_policy"); deletionPolicy == "FORCE" {
url = url + "?force=true"
}
log.Printf("[DEBUG] Deleting Volume %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),
})
if err != nil {
return transport_tpg.HandleNotFoundError(err, d, "Volume")
}
err = NetappOperationWaitTime(
config, res, project, "Deleting Volume", userAgent,
d.Timeout(schema.TimeoutDelete))
if err != nil {
return err
}
log.Printf("[DEBUG] Finished deleting Volume %q: %#v", d.Id(), res)
return nil
}
func resourceNetappVolumeImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
config := meta.(*transport_tpg.Config)
if err := tpgresource.ParseImportId([]string{
"^projects/(?P<project>[^/]+)/locations/(?P<location>[^/]+)/volumes/(?P<name>[^/]+)$",
"^(?P<project>[^/]+)/(?P<location>[^/]+)/(?P<name>[^/]+)$",
"^(?P<location>[^/]+)/(?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/{{location}}/volumes/{{name}}")
if err != nil {
return nil, fmt.Errorf("Error constructing id: %s", err)
}
d.SetId(id)
// Explicitly set virtual fields to default values on import
if err := d.Set("deletion_policy", "DEFAULT"); err != nil {
return nil, fmt.Errorf("Error setting deletion_policy: %s", err)
}
return []*schema.ResourceData{d}, nil
}
func flattenNetappVolumeState(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeStateDetails(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeCreateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeShareName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumePsaRange(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeStoragePool(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeNetwork(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeServiceLevel(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeCapacityGib(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeExportPolicy(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["rules"] =
flattenNetappVolumeExportPolicyRules(original["rules"], d, config)
return []interface{}{transformed}
}
func flattenNetappVolumeExportPolicyRules(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
if v == nil {
return v
}
l := v.([]interface{})
transformed := make([]interface{}, 0, len(l))
for _, raw := range l {
original := raw.(map[string]interface{})
if len(original) < 1 {
// Do not include empty json objects coming back from the api
continue
}
transformed = append(transformed, map[string]interface{}{
"allowed_clients": flattenNetappVolumeExportPolicyRulesAllowedClients(original["allowedClients"], d, config),
"has_root_access": flattenNetappVolumeExportPolicyRulesHasRootAccess(original["hasRootAccess"], d, config),
"access_type": flattenNetappVolumeExportPolicyRulesAccessType(original["accessType"], d, config),
"nfsv3": flattenNetappVolumeExportPolicyRulesNfsv3(original["nfsv3"], d, config),
"nfsv4": flattenNetappVolumeExportPolicyRulesNfsv4(original["nfsv4"], d, config),
"kerberos5_read_only": flattenNetappVolumeExportPolicyRulesKerberos5ReadOnly(original["kerberos5ReadOnly"], d, config),
"kerberos5_read_write": flattenNetappVolumeExportPolicyRulesKerberos5ReadWrite(original["kerberos5ReadWrite"], d, config),
"kerberos5i_read_only": flattenNetappVolumeExportPolicyRulesKerberos5iReadOnly(original["kerberos5iReadOnly"], d, config),
"kerberos5i_read_write": flattenNetappVolumeExportPolicyRulesKerberos5iReadWrite(original["kerberos5iReadWrite"], d, config),
"kerberos5p_read_only": flattenNetappVolumeExportPolicyRulesKerberos5pReadOnly(original["kerberos5pReadOnly"], d, config),
"kerberos5p_read_write": flattenNetappVolumeExportPolicyRulesKerberos5pReadWrite(original["kerberos5pReadWrite"], d, config),
})
}
return transformed
}
func flattenNetappVolumeExportPolicyRulesAllowedClients(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeExportPolicyRulesHasRootAccess(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeExportPolicyRulesAccessType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeExportPolicyRulesNfsv3(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeExportPolicyRulesNfsv4(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeExportPolicyRulesKerberos5ReadOnly(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeExportPolicyRulesKerberos5ReadWrite(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeExportPolicyRulesKerberos5iReadOnly(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeExportPolicyRulesKerberos5iReadWrite(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeExportPolicyRulesKerberos5pReadOnly(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeExportPolicyRulesKerberos5pReadWrite(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeProtocols(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeSmbSettings(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeUnixPermissions(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
if v == nil {
return v
}
transformed := make(map[string]interface{})
if l, ok := d.GetOkExists("labels"); ok {
for k := range l.(map[string]interface{}) {
transformed[k] = v.(map[string]interface{})[k]
}
}
return transformed
}
func flattenNetappVolumeDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeSnapshotDirectory(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeUsedGib(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeSecurityStyle(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeKerberosEnabled(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeLdapEnabled(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeActiveDirectory(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeKmsConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeEncryptionType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeHasReplication(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeRestrictedActions(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeMountOptions(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
if v == nil {
return v
}
l := v.([]interface{})
transformed := make([]interface{}, 0, len(l))
for _, raw := range l {
original := raw.(map[string]interface{})
if len(original) < 1 {
// Do not include empty json objects coming back from the api
continue
}
transformed = append(transformed, map[string]interface{}{
"export": flattenNetappVolumeMountOptionsExport(original["export"], d, config),
"export_full": flattenNetappVolumeMountOptionsExportFull(original["exportFull"], d, config),
"instructions": flattenNetappVolumeMountOptionsInstructions(original["instructions"], d, config),
"protocol": flattenNetappVolumeMountOptionsProtocol(original["protocol"], d, config),
})
}
return transformed
}
func flattenNetappVolumeMountOptionsExport(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeMountOptionsExportFull(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeMountOptionsInstructions(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeMountOptionsProtocol(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeSnapshotPolicy(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["enabled"] =
flattenNetappVolumeSnapshotPolicyEnabled(original["enabled"], d, config)
transformed["hourly_schedule"] =
flattenNetappVolumeSnapshotPolicyHourlySchedule(original["hourlySchedule"], d, config)
transformed["daily_schedule"] =
flattenNetappVolumeSnapshotPolicyDailySchedule(original["dailySchedule"], d, config)
transformed["weekly_schedule"] =
flattenNetappVolumeSnapshotPolicyWeeklySchedule(original["weeklySchedule"], d, config)
transformed["monthly_schedule"] =
flattenNetappVolumeSnapshotPolicyMonthlySchedule(original["monthlySchedule"], d, config)
return []interface{}{transformed}
}
func flattenNetappVolumeSnapshotPolicyEnabled(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeSnapshotPolicyHourlySchedule(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["snapshots_to_keep"] =
flattenNetappVolumeSnapshotPolicyHourlyScheduleSnapshotsToKeep(original["snapshotsToKeep"], d, config)
transformed["minute"] =
flattenNetappVolumeSnapshotPolicyHourlyScheduleMinute(original["minute"], d, config)
return []interface{}{transformed}
}
func flattenNetappVolumeSnapshotPolicyHourlyScheduleSnapshotsToKeep(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 flattenNetappVolumeSnapshotPolicyHourlyScheduleMinute(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 flattenNetappVolumeSnapshotPolicyDailySchedule(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["snapshots_to_keep"] =
flattenNetappVolumeSnapshotPolicyDailyScheduleSnapshotsToKeep(original["snapshotsToKeep"], d, config)
transformed["minute"] =
flattenNetappVolumeSnapshotPolicyDailyScheduleMinute(original["minute"], d, config)
transformed["hour"] =
flattenNetappVolumeSnapshotPolicyDailyScheduleHour(original["hour"], d, config)
return []interface{}{transformed}
}
func flattenNetappVolumeSnapshotPolicyDailyScheduleSnapshotsToKeep(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 flattenNetappVolumeSnapshotPolicyDailyScheduleMinute(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 flattenNetappVolumeSnapshotPolicyDailyScheduleHour(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 flattenNetappVolumeSnapshotPolicyWeeklySchedule(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["snapshots_to_keep"] =
flattenNetappVolumeSnapshotPolicyWeeklyScheduleSnapshotsToKeep(original["snapshotsToKeep"], d, config)
transformed["minute"] =
flattenNetappVolumeSnapshotPolicyWeeklyScheduleMinute(original["minute"], d, config)
transformed["hour"] =
flattenNetappVolumeSnapshotPolicyWeeklyScheduleHour(original["hour"], d, config)
transformed["day"] =
flattenNetappVolumeSnapshotPolicyWeeklyScheduleDay(original["day"], d, config)
return []interface{}{transformed}
}
func flattenNetappVolumeSnapshotPolicyWeeklyScheduleSnapshotsToKeep(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 flattenNetappVolumeSnapshotPolicyWeeklyScheduleMinute(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 flattenNetappVolumeSnapshotPolicyWeeklyScheduleHour(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 flattenNetappVolumeSnapshotPolicyWeeklyScheduleDay(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeSnapshotPolicyMonthlySchedule(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["snapshots_to_keep"] =
flattenNetappVolumeSnapshotPolicyMonthlyScheduleSnapshotsToKeep(original["snapshotsToKeep"], d, config)
transformed["minute"] =
flattenNetappVolumeSnapshotPolicyMonthlyScheduleMinute(original["minute"], d, config)
transformed["hour"] =
flattenNetappVolumeSnapshotPolicyMonthlyScheduleHour(original["hour"], d, config)
transformed["days_of_month"] =
flattenNetappVolumeSnapshotPolicyMonthlyScheduleDaysOfMonth(original["daysOfMonth"], d, config)
return []interface{}{transformed}
}
func flattenNetappVolumeSnapshotPolicyMonthlyScheduleSnapshotsToKeep(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 flattenNetappVolumeSnapshotPolicyMonthlyScheduleMinute(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 flattenNetappVolumeSnapshotPolicyMonthlyScheduleHour(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 flattenNetappVolumeSnapshotPolicyMonthlyScheduleDaysOfMonth(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func flattenNetappVolumeTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
if v == nil {
return v
}
transformed := make(map[string]interface{})
if l, ok := d.GetOkExists("terraform_labels"); ok {
for k := range l.(map[string]interface{}) {
transformed[k] = v.(map[string]interface{})[k]
}
}
return transformed
}
func flattenNetappVolumeEffectiveLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
func expandNetappVolumeShareName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeStoragePool(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeCapacityGib(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeExportPolicy(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{})
transformedRules, err := expandNetappVolumeExportPolicyRules(original["rules"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedRules); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["rules"] = transformedRules
}
return transformed, nil
}
func expandNetappVolumeExportPolicyRules(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
l := v.([]interface{})
req := make([]interface{}, 0, len(l))
for _, raw := range l {
if raw == nil {
continue
}
original := raw.(map[string]interface{})
transformed := make(map[string]interface{})
transformedAllowedClients, err := expandNetappVolumeExportPolicyRulesAllowedClients(original["allowed_clients"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedAllowedClients); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["allowedClients"] = transformedAllowedClients
}
transformedHasRootAccess, err := expandNetappVolumeExportPolicyRulesHasRootAccess(original["has_root_access"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedHasRootAccess); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["hasRootAccess"] = transformedHasRootAccess
}
transformedAccessType, err := expandNetappVolumeExportPolicyRulesAccessType(original["access_type"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedAccessType); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["accessType"] = transformedAccessType
}
transformedNfsv3, err := expandNetappVolumeExportPolicyRulesNfsv3(original["nfsv3"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedNfsv3); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["nfsv3"] = transformedNfsv3
}
transformedNfsv4, err := expandNetappVolumeExportPolicyRulesNfsv4(original["nfsv4"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedNfsv4); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["nfsv4"] = transformedNfsv4
}
transformedKerberos5ReadOnly, err := expandNetappVolumeExportPolicyRulesKerberos5ReadOnly(original["kerberos5_read_only"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedKerberos5ReadOnly); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["kerberos5ReadOnly"] = transformedKerberos5ReadOnly
}
transformedKerberos5ReadWrite, err := expandNetappVolumeExportPolicyRulesKerberos5ReadWrite(original["kerberos5_read_write"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedKerberos5ReadWrite); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["kerberos5ReadWrite"] = transformedKerberos5ReadWrite
}
transformedKerberos5iReadOnly, err := expandNetappVolumeExportPolicyRulesKerberos5iReadOnly(original["kerberos5i_read_only"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedKerberos5iReadOnly); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["kerberos5iReadOnly"] = transformedKerberos5iReadOnly
}
transformedKerberos5iReadWrite, err := expandNetappVolumeExportPolicyRulesKerberos5iReadWrite(original["kerberos5i_read_write"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedKerberos5iReadWrite); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["kerberos5iReadWrite"] = transformedKerberos5iReadWrite
}
transformedKerberos5pReadOnly, err := expandNetappVolumeExportPolicyRulesKerberos5pReadOnly(original["kerberos5p_read_only"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedKerberos5pReadOnly); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["kerberos5pReadOnly"] = transformedKerberos5pReadOnly
}
transformedKerberos5pReadWrite, err := expandNetappVolumeExportPolicyRulesKerberos5pReadWrite(original["kerberos5p_read_write"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedKerberos5pReadWrite); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["kerberos5pReadWrite"] = transformedKerberos5pReadWrite
}
req = append(req, transformed)
}
return req, nil
}
func expandNetappVolumeExportPolicyRulesAllowedClients(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeExportPolicyRulesHasRootAccess(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeExportPolicyRulesAccessType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeExportPolicyRulesNfsv3(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeExportPolicyRulesNfsv4(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeExportPolicyRulesKerberos5ReadOnly(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeExportPolicyRulesKerberos5ReadWrite(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeExportPolicyRulesKerberos5iReadOnly(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeExportPolicyRulesKerberos5iReadWrite(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeExportPolicyRulesKerberos5pReadOnly(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeExportPolicyRulesKerberos5pReadWrite(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeProtocols(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeSmbSettings(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeUnixPermissions(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeSnapshotDirectory(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeSecurityStyle(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeKerberosEnabled(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeRestoreParameters(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{})
transformedSourceSnapshot, err := expandNetappVolumeRestoreParametersSourceSnapshot(original["source_snapshot"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedSourceSnapshot); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["sourceSnapshot"] = transformedSourceSnapshot
}
transformedSourceBackup, err := expandNetappVolumeRestoreParametersSourceBackup(original["source_backup"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedSourceBackup); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["sourceBackup"] = transformedSourceBackup
}
return transformed, nil
}
func expandNetappVolumeRestoreParametersSourceSnapshot(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeRestoreParametersSourceBackup(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeRestrictedActions(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeSnapshotPolicy(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{})
transformedEnabled, err := expandNetappVolumeSnapshotPolicyEnabled(original["enabled"], d, config)
if err != nil {
return nil, err
} else {
transformed["enabled"] = transformedEnabled
}
transformedHourlySchedule, err := expandNetappVolumeSnapshotPolicyHourlySchedule(original["hourly_schedule"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedHourlySchedule); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["hourlySchedule"] = transformedHourlySchedule
}
transformedDailySchedule, err := expandNetappVolumeSnapshotPolicyDailySchedule(original["daily_schedule"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedDailySchedule); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["dailySchedule"] = transformedDailySchedule
}
transformedWeeklySchedule, err := expandNetappVolumeSnapshotPolicyWeeklySchedule(original["weekly_schedule"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedWeeklySchedule); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["weeklySchedule"] = transformedWeeklySchedule
}
transformedMonthlySchedule, err := expandNetappVolumeSnapshotPolicyMonthlySchedule(original["monthly_schedule"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedMonthlySchedule); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["monthlySchedule"] = transformedMonthlySchedule
}
return transformed, nil
}
func expandNetappVolumeSnapshotPolicyEnabled(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeSnapshotPolicyHourlySchedule(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{})
transformedSnapshotsToKeep, err := expandNetappVolumeSnapshotPolicyHourlyScheduleSnapshotsToKeep(original["snapshots_to_keep"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedSnapshotsToKeep); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["snapshotsToKeep"] = transformedSnapshotsToKeep
}
transformedMinute, err := expandNetappVolumeSnapshotPolicyHourlyScheduleMinute(original["minute"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedMinute); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["minute"] = transformedMinute
}
return transformed, nil
}
func expandNetappVolumeSnapshotPolicyHourlyScheduleSnapshotsToKeep(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeSnapshotPolicyHourlyScheduleMinute(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeSnapshotPolicyDailySchedule(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{})
transformedSnapshotsToKeep, err := expandNetappVolumeSnapshotPolicyDailyScheduleSnapshotsToKeep(original["snapshots_to_keep"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedSnapshotsToKeep); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["snapshotsToKeep"] = transformedSnapshotsToKeep
}
transformedMinute, err := expandNetappVolumeSnapshotPolicyDailyScheduleMinute(original["minute"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedMinute); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["minute"] = transformedMinute
}
transformedHour, err := expandNetappVolumeSnapshotPolicyDailyScheduleHour(original["hour"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedHour); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["hour"] = transformedHour
}
return transformed, nil
}
func expandNetappVolumeSnapshotPolicyDailyScheduleSnapshotsToKeep(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeSnapshotPolicyDailyScheduleMinute(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeSnapshotPolicyDailyScheduleHour(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeSnapshotPolicyWeeklySchedule(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{})
transformedSnapshotsToKeep, err := expandNetappVolumeSnapshotPolicyWeeklyScheduleSnapshotsToKeep(original["snapshots_to_keep"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedSnapshotsToKeep); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["snapshotsToKeep"] = transformedSnapshotsToKeep
}
transformedMinute, err := expandNetappVolumeSnapshotPolicyWeeklyScheduleMinute(original["minute"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedMinute); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["minute"] = transformedMinute
}
transformedHour, err := expandNetappVolumeSnapshotPolicyWeeklyScheduleHour(original["hour"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedHour); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["hour"] = transformedHour
}
transformedDay, err := expandNetappVolumeSnapshotPolicyWeeklyScheduleDay(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 expandNetappVolumeSnapshotPolicyWeeklyScheduleSnapshotsToKeep(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeSnapshotPolicyWeeklyScheduleMinute(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeSnapshotPolicyWeeklyScheduleHour(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeSnapshotPolicyWeeklyScheduleDay(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeSnapshotPolicyMonthlySchedule(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{})
transformedSnapshotsToKeep, err := expandNetappVolumeSnapshotPolicyMonthlyScheduleSnapshotsToKeep(original["snapshots_to_keep"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedSnapshotsToKeep); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["snapshotsToKeep"] = transformedSnapshotsToKeep
}
transformedMinute, err := expandNetappVolumeSnapshotPolicyMonthlyScheduleMinute(original["minute"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedMinute); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["minute"] = transformedMinute
}
transformedHour, err := expandNetappVolumeSnapshotPolicyMonthlyScheduleHour(original["hour"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedHour); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["hour"] = transformedHour
}
transformedDaysOfMonth, err := expandNetappVolumeSnapshotPolicyMonthlyScheduleDaysOfMonth(original["days_of_month"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedDaysOfMonth); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["daysOfMonth"] = transformedDaysOfMonth
}
return transformed, nil
}
func expandNetappVolumeSnapshotPolicyMonthlyScheduleSnapshotsToKeep(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeSnapshotPolicyMonthlyScheduleMinute(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeSnapshotPolicyMonthlyScheduleHour(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeSnapshotPolicyMonthlyScheduleDaysOfMonth(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
func expandNetappVolumeEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) {
if v == nil {
return map[string]string{}, nil
}
m := make(map[string]string)
for k, val := range v.(map[string]interface{}) {
m[k] = val.(string)
}
return m, nil
}