-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added
CloudQuotas
service and Create QuotaPreference
Resource (#…
…10019) (#2077) * setup resoruce config and add create tests * add create and update test * fix lint error * fix lint error * update yaml config * remove trailing spaces * modify update test * update acceptance test and cleanup * add upsert scenario for testing * update acceptance test syntax * remove allow-missing flag & fix update test failure * add import and id format * teamcity test failure - manually add cloudquotas service * teamcity test failure - manually add cloudquotas service for beta * add field 'validate_only' to tests * address comments & fix test failure * remove unused import * remove `validate_only` field, add ignore read feature to `annotations` field * add input only fields to ImportStateVerifyIgnore * update field name * VCR test failure: remove batch service creation * fix formatting [upstream:7b41c4afa4f77c38bc1b72ed97bbd8b1aeb22352] Signed-off-by: Modular Magician <[email protected]>
- Loading branch information
1 parent
9e302f9
commit 8dd212e
Showing
3 changed files
with
220 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
217 changes: 217 additions & 0 deletions
217
tfplan2cai/converters/google/resources/services/cloudquotas/cloudquotas_quota_preference.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,217 @@ | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// *** 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 cloudquotas | ||
|
||
import ( | ||
"reflect" | ||
|
||
"github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/cai" | ||
"github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource" | ||
transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" | ||
) | ||
|
||
const CloudQuotasQuotaPreferenceAssetType string = "cloudquotas.googleapis.com/QuotaPreference" | ||
|
||
func ResourceConverterCloudQuotasQuotaPreference() cai.ResourceConverter { | ||
return cai.ResourceConverter{ | ||
AssetType: CloudQuotasQuotaPreferenceAssetType, | ||
Convert: GetCloudQuotasQuotaPreferenceCaiObject, | ||
} | ||
} | ||
|
||
func GetCloudQuotasQuotaPreferenceCaiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) ([]cai.Asset, error) { | ||
name, err := cai.AssetName(d, config, "//cloudquotas.googleapis.com/{{parent}}/locations/global/quotaPreferences/{{name}}") | ||
if err != nil { | ||
return []cai.Asset{}, err | ||
} | ||
if obj, err := GetCloudQuotasQuotaPreferenceApiObject(d, config); err == nil { | ||
return []cai.Asset{{ | ||
Name: name, | ||
Type: CloudQuotasQuotaPreferenceAssetType, | ||
Resource: &cai.AssetResource{ | ||
Version: "v1", | ||
DiscoveryDocumentURI: "https://www.googleapis.com/discovery/v1/apis/cloudquotas/v1/rest", | ||
DiscoveryName: "QuotaPreference", | ||
Data: obj, | ||
}, | ||
}}, nil | ||
} else { | ||
return []cai.Asset{}, err | ||
} | ||
} | ||
|
||
func GetCloudQuotasQuotaPreferenceApiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]interface{}, error) { | ||
obj := make(map[string]interface{}) | ||
nameProp, err := expandCloudQuotasQuotaPreferenceName(d.Get("name"), d, config) | ||
if err != nil { | ||
return nil, err | ||
} else if v, ok := d.GetOkExists("name"); !tpgresource.IsEmptyValue(reflect.ValueOf(nameProp)) && (ok || !reflect.DeepEqual(v, nameProp)) { | ||
obj["name"] = nameProp | ||
} | ||
serviceProp, err := expandCloudQuotasQuotaPreferenceService(d.Get("service"), d, config) | ||
if err != nil { | ||
return nil, err | ||
} else if v, ok := d.GetOkExists("service"); !tpgresource.IsEmptyValue(reflect.ValueOf(serviceProp)) && (ok || !reflect.DeepEqual(v, serviceProp)) { | ||
obj["service"] = serviceProp | ||
} | ||
quotaIdProp, err := expandCloudQuotasQuotaPreferenceQuotaId(d.Get("quota_id"), d, config) | ||
if err != nil { | ||
return nil, err | ||
} else if v, ok := d.GetOkExists("quota_id"); !tpgresource.IsEmptyValue(reflect.ValueOf(quotaIdProp)) && (ok || !reflect.DeepEqual(v, quotaIdProp)) { | ||
obj["quotaId"] = quotaIdProp | ||
} | ||
quotaConfigProp, err := expandCloudQuotasQuotaPreferenceQuotaConfig(d.Get("quota_config"), d, config) | ||
if err != nil { | ||
return nil, err | ||
} else if v, ok := d.GetOkExists("quota_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(quotaConfigProp)) && (ok || !reflect.DeepEqual(v, quotaConfigProp)) { | ||
obj["quotaConfig"] = quotaConfigProp | ||
} | ||
dimensionsProp, err := expandCloudQuotasQuotaPreferenceDimensions(d.Get("dimensions"), d, config) | ||
if err != nil { | ||
return nil, err | ||
} else if v, ok := d.GetOkExists("dimensions"); !tpgresource.IsEmptyValue(reflect.ValueOf(dimensionsProp)) && (ok || !reflect.DeepEqual(v, dimensionsProp)) { | ||
obj["dimensions"] = dimensionsProp | ||
} | ||
justificationProp, err := expandCloudQuotasQuotaPreferenceJustification(d.Get("justification"), d, config) | ||
if err != nil { | ||
return nil, err | ||
} else if v, ok := d.GetOkExists("justification"); !tpgresource.IsEmptyValue(reflect.ValueOf(justificationProp)) && (ok || !reflect.DeepEqual(v, justificationProp)) { | ||
obj["justification"] = justificationProp | ||
} | ||
contactEmailProp, err := expandCloudQuotasQuotaPreferenceContactEmail(d.Get("contact_email"), d, config) | ||
if err != nil { | ||
return nil, err | ||
} else if v, ok := d.GetOkExists("contact_email"); !tpgresource.IsEmptyValue(reflect.ValueOf(contactEmailProp)) && (ok || !reflect.DeepEqual(v, contactEmailProp)) { | ||
obj["contactEmail"] = contactEmailProp | ||
} | ||
|
||
return obj, nil | ||
} | ||
|
||
func expandCloudQuotasQuotaPreferenceName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { | ||
return tpgresource.GetResourceNameFromSelfLink(v.(string)), nil | ||
} | ||
|
||
func expandCloudQuotasQuotaPreferenceService(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { | ||
return v, nil | ||
} | ||
|
||
func expandCloudQuotasQuotaPreferenceQuotaId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { | ||
return v, nil | ||
} | ||
|
||
func expandCloudQuotasQuotaPreferenceQuotaConfig(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{}) | ||
|
||
transformedPreferredValue, err := expandCloudQuotasQuotaPreferenceQuotaConfigPreferredValue(original["preferred_value"], d, config) | ||
if err != nil { | ||
return nil, err | ||
} else if val := reflect.ValueOf(transformedPreferredValue); val.IsValid() && !tpgresource.IsEmptyValue(val) { | ||
transformed["preferredValue"] = transformedPreferredValue | ||
} | ||
|
||
transformedStateDetail, err := expandCloudQuotasQuotaPreferenceQuotaConfigStateDetail(original["state_detail"], d, config) | ||
if err != nil { | ||
return nil, err | ||
} else if val := reflect.ValueOf(transformedStateDetail); val.IsValid() && !tpgresource.IsEmptyValue(val) { | ||
transformed["stateDetail"] = transformedStateDetail | ||
} | ||
|
||
transformedGrantedValue, err := expandCloudQuotasQuotaPreferenceQuotaConfigGrantedValue(original["granted_value"], d, config) | ||
if err != nil { | ||
return nil, err | ||
} else if val := reflect.ValueOf(transformedGrantedValue); val.IsValid() && !tpgresource.IsEmptyValue(val) { | ||
transformed["grantedValue"] = transformedGrantedValue | ||
} | ||
|
||
transformedTraceId, err := expandCloudQuotasQuotaPreferenceQuotaConfigTraceId(original["trace_id"], d, config) | ||
if err != nil { | ||
return nil, err | ||
} else if val := reflect.ValueOf(transformedTraceId); val.IsValid() && !tpgresource.IsEmptyValue(val) { | ||
transformed["traceId"] = transformedTraceId | ||
} | ||
|
||
transformedAnnotations, err := expandCloudQuotasQuotaPreferenceQuotaConfigAnnotations(original["annotations"], d, config) | ||
if err != nil { | ||
return nil, err | ||
} else if val := reflect.ValueOf(transformedAnnotations); val.IsValid() && !tpgresource.IsEmptyValue(val) { | ||
transformed["annotations"] = transformedAnnotations | ||
} | ||
|
||
transformedRequestOrigin, err := expandCloudQuotasQuotaPreferenceQuotaConfigRequestOrigin(original["request_origin"], d, config) | ||
if err != nil { | ||
return nil, err | ||
} else if val := reflect.ValueOf(transformedRequestOrigin); val.IsValid() && !tpgresource.IsEmptyValue(val) { | ||
transformed["requestOrigin"] = transformedRequestOrigin | ||
} | ||
|
||
return transformed, nil | ||
} | ||
|
||
func expandCloudQuotasQuotaPreferenceQuotaConfigPreferredValue(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { | ||
return v, nil | ||
} | ||
|
||
func expandCloudQuotasQuotaPreferenceQuotaConfigStateDetail(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { | ||
return v, nil | ||
} | ||
|
||
func expandCloudQuotasQuotaPreferenceQuotaConfigGrantedValue(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { | ||
return v, nil | ||
} | ||
|
||
func expandCloudQuotasQuotaPreferenceQuotaConfigTraceId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { | ||
return v, nil | ||
} | ||
|
||
func expandCloudQuotasQuotaPreferenceQuotaConfigAnnotations(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 | ||
} | ||
|
||
func expandCloudQuotasQuotaPreferenceQuotaConfigRequestOrigin(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { | ||
return v, nil | ||
} | ||
|
||
func expandCloudQuotasQuotaPreferenceDimensions(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 | ||
} | ||
|
||
func expandCloudQuotasQuotaPreferenceJustification(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { | ||
return v, nil | ||
} | ||
|
||
func expandCloudQuotasQuotaPreferenceContactEmail(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { | ||
return v, nil | ||
} |