Skip to content

Commit

Permalink
Add bigtable app profile resource
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
megan07 authored and modular-magician committed Jul 29, 2019
1 parent 407a94c commit 9144e21
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 0 deletions.
139 changes: 139 additions & 0 deletions google/bigtable_app_profile.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
//
// ----------------------------------------------------------------------------
//
// 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 google

import (
"reflect"

"google.golang.org/api/bigtableadmin/v2"
)

func GetBigtableAppProfileCaiObject(d TerraformResourceData, config *Config) (Asset, error) {
name, err := assetName(d, config, "//bigtable.googleapis.com/projects/{{project}}/instances/{{instance}}/appProfiles/{{app_profile_id}}")
if err != nil {
return Asset{}, err
}
if obj, err := GetBigtableAppProfileApiObject(d, config); err == nil {
return Asset{
Name: name,
Type: "bigtable.googleapis.com/AppProfile",
Resource: &AssetResource{
Version: "v2",
DiscoveryDocumentURI: "https://www.googleapis.com/discovery/v1/apis/bigtable/v2/rest",
DiscoveryName: "AppProfile",
Data: obj,
},
}, nil
} else {
return Asset{}, err
}
}

func GetBigtableAppProfileApiObject(d TerraformResourceData, config *Config) (map[string]interface{}, error) {
obj := make(map[string]interface{})
appProfileIdProp, err := expandBigtableAppProfileAppProfileId(d.Get("app_profile_id"), d, config)
if err != nil {
return nil, err
} else if v, ok := d.GetOkExists("app_profile_id"); !isEmptyValue(reflect.ValueOf(appProfileIdProp)) && (ok || !reflect.DeepEqual(v, appProfileIdProp)) {
obj["appProfileId"] = appProfileIdProp
}
instanceProp, err := expandBigtableAppProfileInstance(d.Get("instance"), d, config)
if err != nil {
return nil, err
} else if v, ok := d.GetOkExists("instance"); !isEmptyValue(reflect.ValueOf(instanceProp)) && (ok || !reflect.DeepEqual(v, instanceProp)) {
obj["instance"] = instanceProp
}
descriptionProp, err := expandBigtableAppProfileDescription(d.Get("description"), d, config)
if err != nil {
return nil, err
} else if v, ok := d.GetOkExists("description"); !isEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) {
obj["description"] = descriptionProp
}
multiClusterRoutingUseAnyProp, err := expandBigtableAppProfileMultiClusterRoutingUseAny(d.Get("multi_cluster_routing_use_any"), d, config)
if err != nil {
return nil, err
} else if v, ok := d.GetOkExists("multi_cluster_routing_use_any"); !isEmptyValue(reflect.ValueOf(multiClusterRoutingUseAnyProp)) && (ok || !reflect.DeepEqual(v, multiClusterRoutingUseAnyProp)) {
obj["multiClusterRoutingUseAny"] = multiClusterRoutingUseAnyProp
}
singleClusterRoutingProp, err := expandBigtableAppProfileSingleClusterRouting(d.Get("single_cluster_routing"), d, config)
if err != nil {
return nil, err
} else if v, ok := d.GetOkExists("single_cluster_routing"); !isEmptyValue(reflect.ValueOf(singleClusterRoutingProp)) && (ok || !reflect.DeepEqual(v, singleClusterRoutingProp)) {
obj["singleClusterRouting"] = singleClusterRoutingProp
}

return resourceBigtableAppProfileEncoder(d, config, obj)
}

func resourceBigtableAppProfileEncoder(d TerraformResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) {
delete(obj, "appProfileId")
delete(obj, "instance")

if mc_routing := d.Get("multi_cluster_routing_use_any").(bool); mc_routing {
obj["multiClusterRoutingUseAny"] = bigtableadmin.MultiClusterRoutingUseAny{}
}

return obj, nil
}

func expandBigtableAppProfileAppProfileId(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}

func expandBigtableAppProfileInstance(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}

func expandBigtableAppProfileDescription(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}

func expandBigtableAppProfileMultiClusterRoutingUseAny(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}

func expandBigtableAppProfileSingleClusterRouting(v interface{}, d TerraformResourceData, config *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{})

transformedClusterId, err := expandBigtableAppProfileSingleClusterRoutingClusterId(original["cluster_id"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedClusterId); val.IsValid() && !isEmptyValue(val) {
transformed["clusterId"] = transformedClusterId
}

transformedAllowTransactionalWrites, err := expandBigtableAppProfileSingleClusterRoutingAllowTransactionalWrites(original["allow_transactional_writes"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedAllowTransactionalWrites); val.IsValid() && !isEmptyValue(val) {
transformed["allowTransactionalWrites"] = transformedAllowTransactionalWrites
}

return transformed, nil
}

func expandBigtableAppProfileSingleClusterRoutingClusterId(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}

func expandBigtableAppProfileSingleClusterRoutingAllowTransactionalWrites(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}
1 change: 1 addition & 0 deletions google/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ type Config struct {

AccessContextManagerBasePath string
AppEngineBasePath string
BigtableBasePath string
BinaryAuthorizationBasePath string
CloudBuildBasePath string
CloudSchedulerBasePath string
Expand Down

0 comments on commit 9144e21

Please sign in to comment.