diff --git a/mmv1/third_party/terraform/go.mod.erb b/mmv1/third_party/terraform/go.mod.erb index 41239ee41bb6..808fdaa8242f 100644 --- a/mmv1/third_party/terraform/go.mod.erb +++ b/mmv1/third_party/terraform/go.mod.erb @@ -4,7 +4,7 @@ module github.com/hashicorp/terraform-provider-google<%= "-" + version unless ve require ( cloud.google.com/go/bigtable v1.10.1 cloud.google.com/go/iam v0.1.1 // indirect - github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220225200700-e76d50f1e637 + github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220304175357-35332d17a512 github.com/apparentlymart/go-cidr v1.1.0 github.com/client9/misspell v0.3.4 github.com/davecgh/go-spew v1.1.1 diff --git a/mmv1/third_party/terraform/go.sum b/mmv1/third_party/terraform/go.sum index 679de1d14a96..a34049ff8695 100644 --- a/mmv1/third_party/terraform/go.sum +++ b/mmv1/third_party/terraform/go.sum @@ -1530,4 +1530,6 @@ rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220225200700-e76d50f1e637 h1:+s2wWcAciNo96AT+Ci9pwXuWm9qlY/ubLFWRaqE0tZg= -github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220225200700-e76d50f1e637/go.mod h1:UJoDYx6t3+xCOd+dZX8+NrEB+Y/eW1pQlvxh2Gt7y5E= \ No newline at end of file +github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220225200700-e76d50f1e637/go.mod h1:UJoDYx6t3+xCOd+dZX8+NrEB+Y/eW1pQlvxh2Gt7y5E= +github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220304175357-35332d17a512 h1:8/Sn9pDdk/RxECtLUh4xum2eyUvf0h7bpx8h+lYvE+Q= +github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220304175357-35332d17a512/go.mod h1:UJoDYx6t3+xCOd+dZX8+NrEB+Y/eW1pQlvxh2Gt7y5E= diff --git a/mmv1/third_party/terraform/utils/config.go.erb b/mmv1/third_party/terraform/utils/config.go.erb index 6901e8d41066..476a8e701aa9 100644 --- a/mmv1/third_party/terraform/utils/config.go.erb +++ b/mmv1/third_party/terraform/utils/config.go.erb @@ -214,6 +214,7 @@ type Config struct { NetworkConnectivityBasePath string OrgPolicyBasePath string RecaptchaEnterpriseBasePath string + ApikeysBasePath string <% if version == 'private' -%> VmwareBasePath string <% end -%> diff --git a/mmv1/third_party/terraform/utils/provider.go.erb b/mmv1/third_party/terraform/utils/provider.go.erb index 7eb206e2d6ec..a71555412658 100644 --- a/mmv1/third_party/terraform/utils/provider.go.erb +++ b/mmv1/third_party/terraform/utils/provider.go.erb @@ -188,6 +188,7 @@ func Provider() *schema.Provider { RecaptchaEnterpriseEndpointEntryKey: RecaptchaEnterpriseEndpointEntry, ContainerAwsCustomEndpointEntryKey: ContainerAwsCustomEndpointEntry, ContainerAzureCustomEndpointEntryKey: ContainerAzureCustomEndpointEntry, + ApikeysEndpointEntryKey: ApikeysEndpointEntry, <% if version == "private" -%> VmwareEndpointEntryKey: VmwareEndpointEntry, @@ -465,6 +466,7 @@ end # products.each do }, // resources implemented within tpgtools map[string]*schema.Resource{ + "google_apikeys_key": resourceApikeysKey(), "google_assured_workloads_workload": resourceAssuredWorkloadsWorkload(), "google_cloudbuild_worker_pool": resourceCloudbuildWorkerPool(), "google_compute_firewall_policy_association": resourceComputeFirewallPolicyAssociation(), @@ -665,6 +667,7 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr config.BigtableAdminBasePath = d.Get(BigtableAdminCustomEndpointEntryKey).(string) // dcl + config.ApikeysBasePath = d.Get(ApikeysEndpointEntryKey).(string) config.AssuredWorkloadsBasePath = d.Get(AssuredWorkloadsEndpointEntryKey).(string) config.CloudResourceManagerBasePath = d.Get(CloudResourceManagerEndpointEntryKey).(string) config.EventarcBasePath = d.Get(EventarcEndpointEntryKey).(string) diff --git a/overrides/apikeys/samples/key/meta.yaml b/overrides/apikeys/samples/key/meta.yaml new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tpgtools/api/apikeys/samples/android.key.json b/tpgtools/api/apikeys/samples/android.key.json new file mode 100755 index 000000000000..8dc4dede79a8 --- /dev/null +++ b/tpgtools/api/apikeys/samples/android.key.json @@ -0,0 +1,21 @@ +{ + "name": "{{key}}", + "project": "{{ref:basic.cloudresourcemanager.project.json:name}}", + "displayName": "sample-key", + "restrictions": { + "androidKeyRestrictions": { + "allowedApplications": [ + { + "packageName": "com.example.app123", + "sha1Fingerprint": "1699466a142d4682a5f91b50fdf400f2358e2b0b" + } + ] + }, + "apiTargets": [ + { + "service": "translate.googleapis.com", + "methods": ["GET*"] + } + ] + } +} diff --git a/tpgtools/api/apikeys/samples/android_key.yaml b/tpgtools/api/apikeys/samples/android_key.yaml new file mode 100755 index 000000000000..9ddaed88bbeb --- /dev/null +++ b/tpgtools/api/apikeys/samples/android_key.yaml @@ -0,0 +1,34 @@ +# Copyright 2022 Google LLC. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +name: android_key +description: A basic example of a android api keys key +type: key +versions: +- ga +resource: samples/android.key.json +dependencies: +- samples/basic.cloudresourcemanager.project.json +updates: +- resource: samples/android_update.key.json + dependencies: + - samples/basic.cloudresourcemanager.project.json +variables: +- name: app + type: resource_name +- name: billing_account + type: billing_account +- name: key + type: resource_name +- name: org_id + type: org_id diff --git a/tpgtools/api/apikeys/samples/android_update.key.json b/tpgtools/api/apikeys/samples/android_update.key.json new file mode 100755 index 000000000000..71b84a6bb2d5 --- /dev/null +++ b/tpgtools/api/apikeys/samples/android_update.key.json @@ -0,0 +1,21 @@ +{ + "name": "{{key}}", + "project": "{{ref:basic.cloudresourcemanager.project.json:name}}", + "displayName": "sample-key", + "restrictions": { + "androidKeyRestrictions": { + "allowedApplications": [ + { + "packageName": "com.example.app124", + "sha1Fingerprint": "1cf89aa28625da86a7e5a7550cf7fd33d611f6fd" + } + ] + }, + "apiTargets": [ + { + "service": "translate.googleapis.com", + "methods": ["GET*"] + } + ] + } +} diff --git a/tpgtools/api/apikeys/samples/apikeys.serviceusage.service.json b/tpgtools/api/apikeys/samples/apikeys.serviceusage.service.json new file mode 100755 index 000000000000..87ed4f510b54 --- /dev/null +++ b/tpgtools/api/apikeys/samples/apikeys.serviceusage.service.json @@ -0,0 +1,5 @@ +{ + "name": "apikeys.googleapis.com", + "project": "{{ref:basic.cloudresourcemanager.project.json:name}}", + "state": "ENABLED" +} diff --git a/tpgtools/api/apikeys/samples/basic.cloudbilling.project_billing_info.json b/tpgtools/api/apikeys/samples/basic.cloudbilling.project_billing_info.json new file mode 100755 index 000000000000..54f385157d61 --- /dev/null +++ b/tpgtools/api/apikeys/samples/basic.cloudbilling.project_billing_info.json @@ -0,0 +1,4 @@ +{ + "name": "{{ref:basic.cloudresourcemanager.project.json:name}}", + "billingAccountName": "{{billing_account}}" +} diff --git a/tpgtools/api/apikeys/samples/basic.cloudresourcemanager.project.json b/tpgtools/api/apikeys/samples/basic.cloudresourcemanager.project.json new file mode 100755 index 000000000000..2ef8040c1b40 --- /dev/null +++ b/tpgtools/api/apikeys/samples/basic.cloudresourcemanager.project.json @@ -0,0 +1,4 @@ +{ + "name": "{{app}}", + "parent": "organizations/{{org_id}}" +} diff --git a/tpgtools/api/apikeys/samples/basic.key.json b/tpgtools/api/apikeys/samples/basic.key.json new file mode 100755 index 000000000000..a319cfc3261f --- /dev/null +++ b/tpgtools/api/apikeys/samples/basic.key.json @@ -0,0 +1,16 @@ +{ + "name": "{{key}}", + "project": "{{ref:basic.cloudresourcemanager.project.json:name}}", + "displayName": "sample-key", + "restrictions": { + "browserKeyRestrictions": { + "allowedReferrers": [".*"] + }, + "apiTargets": [ + { + "service": "translate.googleapis.com", + "methods": ["GET*"] + } + ] + } +} diff --git a/tpgtools/api/apikeys/samples/basic_key.yaml b/tpgtools/api/apikeys/samples/basic_key.yaml new file mode 100755 index 000000000000..d09a4ac717ab --- /dev/null +++ b/tpgtools/api/apikeys/samples/basic_key.yaml @@ -0,0 +1,34 @@ +# Copyright 2022 Google LLC. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +name: basic_key +description: A basic example of a api keys key +type: key +versions: +- ga +resource: samples/basic.key.json +dependencies: +- samples/basic.cloudresourcemanager.project.json +updates: +- resource: samples/update.key.json + dependencies: + - samples/basic.cloudresourcemanager.project.json +variables: +- name: app + type: resource_name +- name: billing_account + type: billing_account +- name: key + type: resource_name +- name: org_id + type: org_id diff --git a/tpgtools/api/apikeys/samples/ios.key.json b/tpgtools/api/apikeys/samples/ios.key.json new file mode 100755 index 000000000000..eeb1bea021e5 --- /dev/null +++ b/tpgtools/api/apikeys/samples/ios.key.json @@ -0,0 +1,16 @@ +{ + "name": "{{key}}", + "project": "{{ref:basic.cloudresourcemanager.project.json:name}}", + "displayName": "sample-key", + "restrictions": { + "iosKeyRestrictions": { + "allowedBundleIds": ["com.google.app.macos"] + }, + "apiTargets": [ + { + "service": "translate.googleapis.com", + "methods": ["GET*"] + } + ] + } +} diff --git a/tpgtools/api/apikeys/samples/ios_key.yaml b/tpgtools/api/apikeys/samples/ios_key.yaml new file mode 100755 index 000000000000..d85ea873f024 --- /dev/null +++ b/tpgtools/api/apikeys/samples/ios_key.yaml @@ -0,0 +1,34 @@ +# Copyright 2022 Google LLC. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +name: ios_key +description: A basic example of a ios api keys key +type: key +versions: +- ga +resource: samples/ios.key.json +dependencies: +- samples/basic.cloudresourcemanager.project.json +updates: +- resource: samples/ios_update.key.json + dependencies: + - samples/basic.cloudresourcemanager.project.json +variables: +- name: app + type: resource_name +- name: billing_account + type: billing_account +- name: key + type: resource_name +- name: org_id + type: org_id diff --git a/tpgtools/api/apikeys/samples/ios_update.key.json b/tpgtools/api/apikeys/samples/ios_update.key.json new file mode 100755 index 000000000000..a45969b4e255 --- /dev/null +++ b/tpgtools/api/apikeys/samples/ios_update.key.json @@ -0,0 +1,16 @@ +{ + "name": "{{key}}", + "project": "{{ref:basic.cloudresourcemanager.project.json:name}}", + "displayName": "sample-key", + "restrictions": { + "iosKeyRestrictions": { + "allowedBundleIds": ["com.google.alex.ios"] + }, + "apiTargets": [ + { + "service": "translate.googleapis.com", + "methods": ["GET*"] + } + ] + } +} diff --git a/tpgtools/api/apikeys/samples/minimal.key.json b/tpgtools/api/apikeys/samples/minimal.key.json new file mode 100755 index 000000000000..0de198c1fb72 --- /dev/null +++ b/tpgtools/api/apikeys/samples/minimal.key.json @@ -0,0 +1,5 @@ +{ + "name": "{{key}}", + "project": "{{ref:basic.cloudresourcemanager.project.json:name}}", + "displayName": "sample-key" +} diff --git a/tpgtools/api/apikeys/samples/minimal_key.yaml b/tpgtools/api/apikeys/samples/minimal_key.yaml new file mode 100755 index 000000000000..899728b04575 --- /dev/null +++ b/tpgtools/api/apikeys/samples/minimal_key.yaml @@ -0,0 +1,30 @@ +# Copyright 2022 Google LLC. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +name: minimal_key +description: A minimal example of a api keys key +type: key +versions: +- ga +resource: samples/minimal.key.json +dependencies: +- samples/basic.cloudresourcemanager.project.json +variables: +- name: app + type: resource_name +- name: billing_account + type: billing_account +- name: key + type: resource_name +- name: org_id + type: org_id diff --git a/tpgtools/api/apikeys/samples/server.key.json b/tpgtools/api/apikeys/samples/server.key.json new file mode 100755 index 000000000000..378cebe04ba8 --- /dev/null +++ b/tpgtools/api/apikeys/samples/server.key.json @@ -0,0 +1,16 @@ +{ + "name": "{{key}}", + "project": "{{ref:basic.cloudresourcemanager.project.json:name}}", + "displayName": "sample-key", + "restrictions": { + "serverKeyRestrictions": { + "allowedIps": ["127.0.0.1"] + }, + "apiTargets": [ + { + "service": "translate.googleapis.com", + "methods": ["GET*"] + } + ] + } +} diff --git a/tpgtools/api/apikeys/samples/server_key.yaml b/tpgtools/api/apikeys/samples/server_key.yaml new file mode 100755 index 000000000000..4f3c1eff1498 --- /dev/null +++ b/tpgtools/api/apikeys/samples/server_key.yaml @@ -0,0 +1,34 @@ +# Copyright 2022 Google LLC. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +name: server_key +description: A basic example of a server api keys key +type: key +versions: +- ga +resource: samples/server.key.json +dependencies: +- samples/basic.cloudresourcemanager.project.json +updates: +- resource: samples/server_update.key.json + dependencies: + - samples/basic.cloudresourcemanager.project.json +variables: +- name: app + type: resource_name +- name: billing_account + type: billing_account +- name: key + type: resource_name +- name: org_id + type: org_id diff --git a/tpgtools/api/apikeys/samples/server_update.key.json b/tpgtools/api/apikeys/samples/server_update.key.json new file mode 100755 index 000000000000..9fb285ce1256 --- /dev/null +++ b/tpgtools/api/apikeys/samples/server_update.key.json @@ -0,0 +1,16 @@ +{ + "name": "{{key}}", + "project": "{{ref:basic.cloudresourcemanager.project.json:name}}", + "displayName": "sample-key", + "restrictions": { + "serverKeyRestrictions": { + "allowedIps": ["127.0.0.2", "192.168.1.1"] + }, + "apiTargets": [ + { + "service": "translate.googleapis.com", + "methods": ["GET*"] + } + ] + } +} diff --git a/tpgtools/api/apikeys/samples/update.key.json b/tpgtools/api/apikeys/samples/update.key.json new file mode 100755 index 000000000000..82e961a9c4eb --- /dev/null +++ b/tpgtools/api/apikeys/samples/update.key.json @@ -0,0 +1,16 @@ +{ + "name":"{{key}}", + "project": "{{ref:basic.cloudresourcemanager.project.json:name}}", + "displayName": "sample-key-update", + "restrictions": { + "browserKeyRestrictions": { + "allowedReferrers": [".*com"] + }, + "apiTargets": [ + { + "service": "maps.googleapis.com", + "methods": ["POST*"] + } + ] + } +} diff --git a/tpgtools/go.mod b/tpgtools/go.mod index 067f440e9f28..8635d937a2f7 100644 --- a/tpgtools/go.mod +++ b/tpgtools/go.mod @@ -4,7 +4,7 @@ go 1.16 require ( bitbucket.org/creachadair/stringset v0.0.9 - github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220225200700-e76d50f1e637 + github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220304175357-35332d17a512 github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b github.com/hashicorp/errwrap v1.0.0 github.com/hashicorp/hcl v1.0.0 diff --git a/tpgtools/go.sum b/tpgtools/go.sum index 50640bf516da..d7c5eb5a76d9 100644 --- a/tpgtools/go.sum +++ b/tpgtools/go.sum @@ -36,8 +36,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220225200700-e76d50f1e637 h1:+s2wWcAciNo96AT+Ci9pwXuWm9qlY/ubLFWRaqE0tZg= -github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220225200700-e76d50f1e637/go.mod h1:UJoDYx6t3+xCOd+dZX8+NrEB+Y/eW1pQlvxh2Gt7y5E= +github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220304175357-35332d17a512 h1:8/Sn9pDdk/RxECtLUh4xum2eyUvf0h7bpx8h+lYvE+Q= +github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220304175357-35332d17a512/go.mod h1:UJoDYx6t3+xCOd+dZX8+NrEB+Y/eW1pQlvxh2Gt7y5E= github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE= github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= diff --git a/tpgtools/overrides/apikeys/beta/key.yaml b/tpgtools/overrides/apikeys/beta/key.yaml new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tpgtools/overrides/apikeys/key.yaml b/tpgtools/overrides/apikeys/key.yaml new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tpgtools/overrides/apikeys/samples/key/meta.yaml b/tpgtools/overrides/apikeys/samples/key/meta.yaml new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tpgtools/property.go b/tpgtools/property.go index b9a9c10d4089..0a45c0acfb1c 100644 --- a/tpgtools/property.go +++ b/tpgtools/property.go @@ -641,7 +641,10 @@ func createPropertiesFromSchema(schema *openapi.Schema, typeFetcher *TypeFetcher } if !p.Computed { - glog.Infof("Looking for %q in %v.", v.Title, schema.Required) + if v.Title == "allowedApplications" { + glog.Errorf("Looking for %#v.", schema) + } + glog.Errorf("Looking for %q in %v.", v.Title, schema.Required) if stringInSlice(v.Title, schema.Required) { p.Required = true } else { diff --git a/tpgtools/serialization.go b/tpgtools/serialization.go index eba1a7a5f11e..b2697f90fc3f 100644 --- a/tpgtools/serialization.go +++ b/tpgtools/serialization.go @@ -21,8 +21,12 @@ import ( "fmt" "strings" + apikeys "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/apikeys" + apikeysBeta "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/apikeys/beta" assuredworkloads "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/assuredworkloads" assuredworkloadsBeta "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/assuredworkloads/beta" + bigqueryreservation "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation" + bigqueryreservationBeta "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/beta" cloudbuild "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/cloudbuild" cloudbuildBeta "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/cloudbuild/beta" cloudresourcemanager "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/cloudresourcemanager" @@ -61,8 +65,12 @@ func DCLToTerraformReference(product DCLPackageName, resource miscellaneousNameS } if version == "beta" { switch fmt.Sprintf("%s/%s", product, resource) { + case "apikeys/key": + return "google_apikeys_key", nil case "assuredworkloads/workload": return "google_assured_workloads_workload", nil + case "bigqueryreservation/assignment": + return "google_bigquery_reservation_assignment", nil case "cloudbuild/worker_pool": return "google_cloudbuild_worker_pool", nil case "cloudresourcemanager/folder": @@ -115,8 +123,12 @@ func DCLToTerraformReference(product DCLPackageName, resource miscellaneousNameS } // If not found in sample version, fallthrough to GA switch fmt.Sprintf("%s/%s", product, resource) { + case "apikeys/key": + return "google_apikeys_key", nil case "assuredworkloads/workload": return "google_assured_workloads_workload", nil + case "bigqueryreservation/assignment": + return "google_bigquery_reservation_assignment", nil case "cloudbuild/worker_pool": return "google_cloudbuild_worker_pool", nil case "cloudresourcemanager/folder": @@ -173,12 +185,24 @@ func ConvertSampleJSONToHCL(product DCLPackageName, resource miscellaneousNameSn } if version == "beta" { switch fmt.Sprintf("%s/%s", product, resource) { + case "apikeys/key": + r := &apikeysBeta.Key{} + if err := json.Unmarshal(b, r); err != nil { + return "", err + } + return ApikeysKeyBetaAsHCL(*r, hasGAEquivalent) case "assuredworkloads/workload": r := &assuredworkloadsBeta.Workload{} if err := json.Unmarshal(b, r); err != nil { return "", err } return AssuredWorkloadsWorkloadBetaAsHCL(*r, hasGAEquivalent) + case "bigqueryreservation/assignment": + r := &bigqueryreservationBeta.Assignment{} + if err := json.Unmarshal(b, r); err != nil { + return "", err + } + return BigqueryReservationAssignmentBetaAsHCL(*r, hasGAEquivalent) case "cloudbuild/worker_pool": r := &cloudbuildBeta.WorkerPool{} if err := json.Unmarshal(b, r); err != nil { @@ -327,12 +351,24 @@ func ConvertSampleJSONToHCL(product DCLPackageName, resource miscellaneousNameSn } // If not found in sample version, fallthrough to GA switch fmt.Sprintf("%s/%s", product, resource) { + case "apikeys/key": + r := &apikeys.Key{} + if err := json.Unmarshal(b, r); err != nil { + return "", err + } + return ApikeysKeyAsHCL(*r, hasGAEquivalent) case "assuredworkloads/workload": r := &assuredworkloads.Workload{} if err := json.Unmarshal(b, r); err != nil { return "", err } return AssuredWorkloadsWorkloadAsHCL(*r, hasGAEquivalent) + case "bigqueryreservation/assignment": + r := &bigqueryreservation.Assignment{} + if err := json.Unmarshal(b, r); err != nil { + return "", err + } + return BigqueryReservationAssignmentAsHCL(*r, hasGAEquivalent) case "cloudbuild/worker_pool": r := &cloudbuild.WorkerPool{} if err := json.Unmarshal(b, r); err != nil { @@ -465,6 +501,152 @@ func ConvertSampleJSONToHCL(product DCLPackageName, resource miscellaneousNameSn } +// ApikeysKeyBetaAsHCL returns a string representation of the specified resource in HCL. +// The generated HCL will include every settable field as a literal - that is, no +// variables, no references. This may not be the best possible representation, but +// the crucial point is that `terraform import; terraform apply` will not produce +// any changes. We do not validate that the resource specified will pass terraform +// validation unless is an object returned from the API after an Apply. +func ApikeysKeyBetaAsHCL(r apikeysBeta.Key, hasGAEquivalent bool) (string, error) { + outputConfig := "resource \"google_apikeys_key\" \"output\" {\n" + if r.Name != nil { + outputConfig += fmt.Sprintf("\tname = %#v\n", *r.Name) + } + if r.DisplayName != nil { + outputConfig += fmt.Sprintf("\tdisplay_name = %#v\n", *r.DisplayName) + } + if r.Project != nil { + outputConfig += fmt.Sprintf("\tproject = %#v\n", *r.Project) + } + if v := convertApikeysKeyBetaRestrictionsToHCL(r.Restrictions); v != "" { + outputConfig += fmt.Sprintf("\trestrictions %s\n", v) + } + formatted, err := formatHCL(outputConfig + "}") + if err != nil { + return "", err + } + if !hasGAEquivalent { + // The formatter will not accept the google-beta symbol because it is injected during testing. + return withProviderLine(formatted), nil + } + return formatted, nil +} + +func convertApikeysKeyBetaRestrictionsToHCL(r *apikeysBeta.KeyRestrictions) string { + if r == nil { + return "" + } + outputConfig := "{\n" + if v := convertApikeysKeyBetaRestrictionsAndroidKeyRestrictionsToHCL(r.AndroidKeyRestrictions); v != "" { + outputConfig += fmt.Sprintf("\tandroid_key_restrictions %s\n", v) + } + if r.ApiTargets != nil { + for _, v := range r.ApiTargets { + outputConfig += fmt.Sprintf("\tapi_targets %s\n", convertApikeysKeyBetaRestrictionsApiTargetsToHCL(&v)) + } + } + if v := convertApikeysKeyBetaRestrictionsBrowserKeyRestrictionsToHCL(r.BrowserKeyRestrictions); v != "" { + outputConfig += fmt.Sprintf("\tbrowser_key_restrictions %s\n", v) + } + if v := convertApikeysKeyBetaRestrictionsIosKeyRestrictionsToHCL(r.IosKeyRestrictions); v != "" { + outputConfig += fmt.Sprintf("\tios_key_restrictions %s\n", v) + } + if v := convertApikeysKeyBetaRestrictionsServerKeyRestrictionsToHCL(r.ServerKeyRestrictions); v != "" { + outputConfig += fmt.Sprintf("\tserver_key_restrictions %s\n", v) + } + return outputConfig + "}" +} + +func convertApikeysKeyBetaRestrictionsAndroidKeyRestrictionsToHCL(r *apikeysBeta.KeyRestrictionsAndroidKeyRestrictions) string { + if r == nil { + return "" + } + outputConfig := "{\n" + if r.AllowedApplications != nil { + for _, v := range r.AllowedApplications { + outputConfig += fmt.Sprintf("\tallowed_applications %s\n", convertApikeysKeyBetaRestrictionsAndroidKeyRestrictionsAllowedApplicationsToHCL(&v)) + } + } + return outputConfig + "}" +} + +func convertApikeysKeyBetaRestrictionsAndroidKeyRestrictionsAllowedApplicationsToHCL(r *apikeysBeta.KeyRestrictionsAndroidKeyRestrictionsAllowedApplications) string { + if r == nil { + return "" + } + outputConfig := "{\n" + if r.PackageName != nil { + outputConfig += fmt.Sprintf("\tpackage_name = %#v\n", *r.PackageName) + } + if r.Sha1Fingerprint != nil { + outputConfig += fmt.Sprintf("\tsha1_fingerprint = %#v\n", *r.Sha1Fingerprint) + } + return outputConfig + "}" +} + +func convertApikeysKeyBetaRestrictionsApiTargetsToHCL(r *apikeysBeta.KeyRestrictionsApiTargets) string { + if r == nil { + return "" + } + outputConfig := "{\n" + if r.Methods != nil { + outputConfig += "\tmethods = [" + for _, v := range r.Methods { + outputConfig += fmt.Sprintf("%#v, ", v) + } + outputConfig += "]\n" + } + if r.Service != nil { + outputConfig += fmt.Sprintf("\tservice = %#v\n", *r.Service) + } + return outputConfig + "}" +} + +func convertApikeysKeyBetaRestrictionsBrowserKeyRestrictionsToHCL(r *apikeysBeta.KeyRestrictionsBrowserKeyRestrictions) string { + if r == nil { + return "" + } + outputConfig := "{\n" + if r.AllowedReferrers != nil { + outputConfig += "\tallowed_referrers = [" + for _, v := range r.AllowedReferrers { + outputConfig += fmt.Sprintf("%#v, ", v) + } + outputConfig += "]\n" + } + return outputConfig + "}" +} + +func convertApikeysKeyBetaRestrictionsIosKeyRestrictionsToHCL(r *apikeysBeta.KeyRestrictionsIosKeyRestrictions) string { + if r == nil { + return "" + } + outputConfig := "{\n" + if r.AllowedBundleIds != nil { + outputConfig += "\tallowed_bundle_ids = [" + for _, v := range r.AllowedBundleIds { + outputConfig += fmt.Sprintf("%#v, ", v) + } + outputConfig += "]\n" + } + return outputConfig + "}" +} + +func convertApikeysKeyBetaRestrictionsServerKeyRestrictionsToHCL(r *apikeysBeta.KeyRestrictionsServerKeyRestrictions) string { + if r == nil { + return "" + } + outputConfig := "{\n" + if r.AllowedIps != nil { + outputConfig += "\tallowed_ips = [" + for _, v := range r.AllowedIps { + outputConfig += fmt.Sprintf("%#v, ", v) + } + outputConfig += "]\n" + } + return outputConfig + "}" +} + // AssuredWorkloadsWorkloadBetaAsHCL returns a string representation of the specified resource in HCL. // The generated HCL will include every settable field as a literal - that is, no // variables, no references. This may not be the best possible representation, but @@ -551,6 +733,40 @@ func convertAssuredWorkloadsWorkloadBetaResourcesToHCL(r *assuredworkloadsBeta.W return outputConfig + "}" } +// BigqueryReservationAssignmentBetaAsHCL returns a string representation of the specified resource in HCL. +// The generated HCL will include every settable field as a literal - that is, no +// variables, no references. This may not be the best possible representation, but +// the crucial point is that `terraform import; terraform apply` will not produce +// any changes. We do not validate that the resource specified will pass terraform +// validation unless is an object returned from the API after an Apply. +func BigqueryReservationAssignmentBetaAsHCL(r bigqueryreservationBeta.Assignment, hasGAEquivalent bool) (string, error) { + outputConfig := "resource \"google_bigquery_reservation_assignment\" \"output\" {\n" + if r.Assignee != nil { + outputConfig += fmt.Sprintf("\tassignee = %#v\n", *r.Assignee) + } + if r.JobType != nil { + outputConfig += fmt.Sprintf("\tjob_type = %#v\n", *r.JobType) + } + if r.Reservation != nil { + outputConfig += fmt.Sprintf("\treservation = %#v\n", *r.Reservation) + } + if r.Location != nil { + outputConfig += fmt.Sprintf("\tlocation = %#v\n", *r.Location) + } + if r.Project != nil { + outputConfig += fmt.Sprintf("\tproject = %#v\n", *r.Project) + } + formatted, err := formatHCL(outputConfig + "}") + if err != nil { + return "", err + } + if !hasGAEquivalent { + // The formatter will not accept the google-beta symbol because it is injected during testing. + return withProviderLine(formatted), nil + } + return formatted, nil +} + // CloudbuildWorkerPoolBetaAsHCL returns a string representation of the specified resource in HCL. // The generated HCL will include every settable field as a literal - that is, no // variables, no references. This may not be the best possible representation, but @@ -5027,6 +5243,152 @@ func convertRecaptchaEnterpriseKeyBetaWebSettingsToHCL(r *recaptchaenterpriseBet return outputConfig + "}" } +// ApikeysKeyAsHCL returns a string representation of the specified resource in HCL. +// The generated HCL will include every settable field as a literal - that is, no +// variables, no references. This may not be the best possible representation, but +// the crucial point is that `terraform import; terraform apply` will not produce +// any changes. We do not validate that the resource specified will pass terraform +// validation unless is an object returned from the API after an Apply. +func ApikeysKeyAsHCL(r apikeys.Key, hasGAEquivalent bool) (string, error) { + outputConfig := "resource \"google_apikeys_key\" \"output\" {\n" + if r.Name != nil { + outputConfig += fmt.Sprintf("\tname = %#v\n", *r.Name) + } + if r.DisplayName != nil { + outputConfig += fmt.Sprintf("\tdisplay_name = %#v\n", *r.DisplayName) + } + if r.Project != nil { + outputConfig += fmt.Sprintf("\tproject = %#v\n", *r.Project) + } + if v := convertApikeysKeyRestrictionsToHCL(r.Restrictions); v != "" { + outputConfig += fmt.Sprintf("\trestrictions %s\n", v) + } + formatted, err := formatHCL(outputConfig + "}") + if err != nil { + return "", err + } + if !hasGAEquivalent { + // The formatter will not accept the google-beta symbol because it is injected during testing. + return withProviderLine(formatted), nil + } + return formatted, nil +} + +func convertApikeysKeyRestrictionsToHCL(r *apikeys.KeyRestrictions) string { + if r == nil { + return "" + } + outputConfig := "{\n" + if v := convertApikeysKeyRestrictionsAndroidKeyRestrictionsToHCL(r.AndroidKeyRestrictions); v != "" { + outputConfig += fmt.Sprintf("\tandroid_key_restrictions %s\n", v) + } + if r.ApiTargets != nil { + for _, v := range r.ApiTargets { + outputConfig += fmt.Sprintf("\tapi_targets %s\n", convertApikeysKeyRestrictionsApiTargetsToHCL(&v)) + } + } + if v := convertApikeysKeyRestrictionsBrowserKeyRestrictionsToHCL(r.BrowserKeyRestrictions); v != "" { + outputConfig += fmt.Sprintf("\tbrowser_key_restrictions %s\n", v) + } + if v := convertApikeysKeyRestrictionsIosKeyRestrictionsToHCL(r.IosKeyRestrictions); v != "" { + outputConfig += fmt.Sprintf("\tios_key_restrictions %s\n", v) + } + if v := convertApikeysKeyRestrictionsServerKeyRestrictionsToHCL(r.ServerKeyRestrictions); v != "" { + outputConfig += fmt.Sprintf("\tserver_key_restrictions %s\n", v) + } + return outputConfig + "}" +} + +func convertApikeysKeyRestrictionsAndroidKeyRestrictionsToHCL(r *apikeys.KeyRestrictionsAndroidKeyRestrictions) string { + if r == nil { + return "" + } + outputConfig := "{\n" + if r.AllowedApplications != nil { + for _, v := range r.AllowedApplications { + outputConfig += fmt.Sprintf("\tallowed_applications %s\n", convertApikeysKeyRestrictionsAndroidKeyRestrictionsAllowedApplicationsToHCL(&v)) + } + } + return outputConfig + "}" +} + +func convertApikeysKeyRestrictionsAndroidKeyRestrictionsAllowedApplicationsToHCL(r *apikeys.KeyRestrictionsAndroidKeyRestrictionsAllowedApplications) string { + if r == nil { + return "" + } + outputConfig := "{\n" + if r.PackageName != nil { + outputConfig += fmt.Sprintf("\tpackage_name = %#v\n", *r.PackageName) + } + if r.Sha1Fingerprint != nil { + outputConfig += fmt.Sprintf("\tsha1_fingerprint = %#v\n", *r.Sha1Fingerprint) + } + return outputConfig + "}" +} + +func convertApikeysKeyRestrictionsApiTargetsToHCL(r *apikeys.KeyRestrictionsApiTargets) string { + if r == nil { + return "" + } + outputConfig := "{\n" + if r.Methods != nil { + outputConfig += "\tmethods = [" + for _, v := range r.Methods { + outputConfig += fmt.Sprintf("%#v, ", v) + } + outputConfig += "]\n" + } + if r.Service != nil { + outputConfig += fmt.Sprintf("\tservice = %#v\n", *r.Service) + } + return outputConfig + "}" +} + +func convertApikeysKeyRestrictionsBrowserKeyRestrictionsToHCL(r *apikeys.KeyRestrictionsBrowserKeyRestrictions) string { + if r == nil { + return "" + } + outputConfig := "{\n" + if r.AllowedReferrers != nil { + outputConfig += "\tallowed_referrers = [" + for _, v := range r.AllowedReferrers { + outputConfig += fmt.Sprintf("%#v, ", v) + } + outputConfig += "]\n" + } + return outputConfig + "}" +} + +func convertApikeysKeyRestrictionsIosKeyRestrictionsToHCL(r *apikeys.KeyRestrictionsIosKeyRestrictions) string { + if r == nil { + return "" + } + outputConfig := "{\n" + if r.AllowedBundleIds != nil { + outputConfig += "\tallowed_bundle_ids = [" + for _, v := range r.AllowedBundleIds { + outputConfig += fmt.Sprintf("%#v, ", v) + } + outputConfig += "]\n" + } + return outputConfig + "}" +} + +func convertApikeysKeyRestrictionsServerKeyRestrictionsToHCL(r *apikeys.KeyRestrictionsServerKeyRestrictions) string { + if r == nil { + return "" + } + outputConfig := "{\n" + if r.AllowedIps != nil { + outputConfig += "\tallowed_ips = [" + for _, v := range r.AllowedIps { + outputConfig += fmt.Sprintf("%#v, ", v) + } + outputConfig += "]\n" + } + return outputConfig + "}" +} + // AssuredWorkloadsWorkloadAsHCL returns a string representation of the specified resource in HCL. // The generated HCL will include every settable field as a literal - that is, no // variables, no references. This may not be the best possible representation, but @@ -5102,15 +5464,49 @@ func convertAssuredWorkloadsWorkloadResourceSettingsToHCL(r *assuredworkloads.Wo if r.ResourceType != nil { outputConfig += fmt.Sprintf("\tresource_type = %#v\n", *r.ResourceType) } - return outputConfig + "}" -} - -func convertAssuredWorkloadsWorkloadResourcesToHCL(r *assuredworkloads.WorkloadResources) string { - if r == nil { - return "" + return outputConfig + "}" +} + +func convertAssuredWorkloadsWorkloadResourcesToHCL(r *assuredworkloads.WorkloadResources) string { + if r == nil { + return "" + } + outputConfig := "{\n" + return outputConfig + "}" +} + +// BigqueryReservationAssignmentAsHCL returns a string representation of the specified resource in HCL. +// The generated HCL will include every settable field as a literal - that is, no +// variables, no references. This may not be the best possible representation, but +// the crucial point is that `terraform import; terraform apply` will not produce +// any changes. We do not validate that the resource specified will pass terraform +// validation unless is an object returned from the API after an Apply. +func BigqueryReservationAssignmentAsHCL(r bigqueryreservation.Assignment, hasGAEquivalent bool) (string, error) { + outputConfig := "resource \"google_bigquery_reservation_assignment\" \"output\" {\n" + if r.Assignee != nil { + outputConfig += fmt.Sprintf("\tassignee = %#v\n", *r.Assignee) + } + if r.JobType != nil { + outputConfig += fmt.Sprintf("\tjob_type = %#v\n", *r.JobType) + } + if r.Reservation != nil { + outputConfig += fmt.Sprintf("\treservation = %#v\n", *r.Reservation) + } + if r.Location != nil { + outputConfig += fmt.Sprintf("\tlocation = %#v\n", *r.Location) + } + if r.Project != nil { + outputConfig += fmt.Sprintf("\tproject = %#v\n", *r.Project) + } + formatted, err := formatHCL(outputConfig + "}") + if err != nil { + return "", err } - outputConfig := "{\n" - return outputConfig + "}" + if !hasGAEquivalent { + // The formatter will not accept the google-beta symbol because it is injected during testing. + return withProviderLine(formatted), nil + } + return formatted, nil } // CloudbuildWorkerPoolAsHCL returns a string representation of the specified resource in HCL. @@ -9279,6 +9675,159 @@ func convertRecaptchaEnterpriseKeyWebSettingsToHCL(r *recaptchaenterprise.KeyWeb return outputConfig + "}" } +func convertApikeysKeyBetaRestrictions(i interface{}) map[string]interface{} { + if i == nil { + return nil + } + in := i.(map[string]interface{}) + return map[string]interface{}{ + "androidKeyRestrictions": convertApikeysKeyBetaRestrictionsAndroidKeyRestrictions(in["android_key_restrictions"]), + "apiTargets": in["api_targets"], + "browserKeyRestrictions": convertApikeysKeyBetaRestrictionsBrowserKeyRestrictions(in["browser_key_restrictions"]), + "iosKeyRestrictions": convertApikeysKeyBetaRestrictionsIosKeyRestrictions(in["ios_key_restrictions"]), + "serverKeyRestrictions": convertApikeysKeyBetaRestrictionsServerKeyRestrictions(in["server_key_restrictions"]), + } +} + +func convertApikeysKeyBetaRestrictionsList(i interface{}) (out []map[string]interface{}) { + if i == nil { + return nil + } + + for _, v := range i.([]interface{}) { + out = append(out, convertApikeysKeyBetaRestrictions(v)) + } + return out +} + +func convertApikeysKeyBetaRestrictionsAndroidKeyRestrictions(i interface{}) map[string]interface{} { + if i == nil { + return nil + } + in := i.(map[string]interface{}) + return map[string]interface{}{ + "allowedApplications": in["allowed_applications"], + } +} + +func convertApikeysKeyBetaRestrictionsAndroidKeyRestrictionsList(i interface{}) (out []map[string]interface{}) { + if i == nil { + return nil + } + + for _, v := range i.([]interface{}) { + out = append(out, convertApikeysKeyBetaRestrictionsAndroidKeyRestrictions(v)) + } + return out +} + +func convertApikeysKeyBetaRestrictionsAndroidKeyRestrictionsAllowedApplications(i interface{}) map[string]interface{} { + if i == nil { + return nil + } + in := i.(map[string]interface{}) + return map[string]interface{}{ + "packageName": in["package_name"], + "sha1Fingerprint": in["sha1_fingerprint"], + } +} + +func convertApikeysKeyBetaRestrictionsAndroidKeyRestrictionsAllowedApplicationsList(i interface{}) (out []map[string]interface{}) { + if i == nil { + return nil + } + + for _, v := range i.([]interface{}) { + out = append(out, convertApikeysKeyBetaRestrictionsAndroidKeyRestrictionsAllowedApplications(v)) + } + return out +} + +func convertApikeysKeyBetaRestrictionsApiTargets(i interface{}) map[string]interface{} { + if i == nil { + return nil + } + in := i.(map[string]interface{}) + return map[string]interface{}{ + "methods": in["methods"], + "service": in["service"], + } +} + +func convertApikeysKeyBetaRestrictionsApiTargetsList(i interface{}) (out []map[string]interface{}) { + if i == nil { + return nil + } + + for _, v := range i.([]interface{}) { + out = append(out, convertApikeysKeyBetaRestrictionsApiTargets(v)) + } + return out +} + +func convertApikeysKeyBetaRestrictionsBrowserKeyRestrictions(i interface{}) map[string]interface{} { + if i == nil { + return nil + } + in := i.(map[string]interface{}) + return map[string]interface{}{ + "allowedReferrers": in["allowed_referrers"], + } +} + +func convertApikeysKeyBetaRestrictionsBrowserKeyRestrictionsList(i interface{}) (out []map[string]interface{}) { + if i == nil { + return nil + } + + for _, v := range i.([]interface{}) { + out = append(out, convertApikeysKeyBetaRestrictionsBrowserKeyRestrictions(v)) + } + return out +} + +func convertApikeysKeyBetaRestrictionsIosKeyRestrictions(i interface{}) map[string]interface{} { + if i == nil { + return nil + } + in := i.(map[string]interface{}) + return map[string]interface{}{ + "allowedBundleIds": in["allowed_bundle_ids"], + } +} + +func convertApikeysKeyBetaRestrictionsIosKeyRestrictionsList(i interface{}) (out []map[string]interface{}) { + if i == nil { + return nil + } + + for _, v := range i.([]interface{}) { + out = append(out, convertApikeysKeyBetaRestrictionsIosKeyRestrictions(v)) + } + return out +} + +func convertApikeysKeyBetaRestrictionsServerKeyRestrictions(i interface{}) map[string]interface{} { + if i == nil { + return nil + } + in := i.(map[string]interface{}) + return map[string]interface{}{ + "allowedIps": in["allowed_ips"], + } +} + +func convertApikeysKeyBetaRestrictionsServerKeyRestrictionsList(i interface{}) (out []map[string]interface{}) { + if i == nil { + return nil + } + + for _, v := range i.([]interface{}) { + out = append(out, convertApikeysKeyBetaRestrictionsServerKeyRestrictions(v)) + } + return out +} + func convertAssuredWorkloadsWorkloadBetaKmsSettings(i interface{}) map[string]interface{} { if i == nil { return nil @@ -13618,6 +14167,159 @@ func convertRecaptchaEnterpriseKeyBetaWebSettingsList(i interface{}) (out []map[ return out } +func convertApikeysKeyRestrictions(i interface{}) map[string]interface{} { + if i == nil { + return nil + } + in := i.(map[string]interface{}) + return map[string]interface{}{ + "androidKeyRestrictions": convertApikeysKeyRestrictionsAndroidKeyRestrictions(in["android_key_restrictions"]), + "apiTargets": in["api_targets"], + "browserKeyRestrictions": convertApikeysKeyRestrictionsBrowserKeyRestrictions(in["browser_key_restrictions"]), + "iosKeyRestrictions": convertApikeysKeyRestrictionsIosKeyRestrictions(in["ios_key_restrictions"]), + "serverKeyRestrictions": convertApikeysKeyRestrictionsServerKeyRestrictions(in["server_key_restrictions"]), + } +} + +func convertApikeysKeyRestrictionsList(i interface{}) (out []map[string]interface{}) { + if i == nil { + return nil + } + + for _, v := range i.([]interface{}) { + out = append(out, convertApikeysKeyRestrictions(v)) + } + return out +} + +func convertApikeysKeyRestrictionsAndroidKeyRestrictions(i interface{}) map[string]interface{} { + if i == nil { + return nil + } + in := i.(map[string]interface{}) + return map[string]interface{}{ + "allowedApplications": in["allowed_applications"], + } +} + +func convertApikeysKeyRestrictionsAndroidKeyRestrictionsList(i interface{}) (out []map[string]interface{}) { + if i == nil { + return nil + } + + for _, v := range i.([]interface{}) { + out = append(out, convertApikeysKeyRestrictionsAndroidKeyRestrictions(v)) + } + return out +} + +func convertApikeysKeyRestrictionsAndroidKeyRestrictionsAllowedApplications(i interface{}) map[string]interface{} { + if i == nil { + return nil + } + in := i.(map[string]interface{}) + return map[string]interface{}{ + "packageName": in["package_name"], + "sha1Fingerprint": in["sha1_fingerprint"], + } +} + +func convertApikeysKeyRestrictionsAndroidKeyRestrictionsAllowedApplicationsList(i interface{}) (out []map[string]interface{}) { + if i == nil { + return nil + } + + for _, v := range i.([]interface{}) { + out = append(out, convertApikeysKeyRestrictionsAndroidKeyRestrictionsAllowedApplications(v)) + } + return out +} + +func convertApikeysKeyRestrictionsApiTargets(i interface{}) map[string]interface{} { + if i == nil { + return nil + } + in := i.(map[string]interface{}) + return map[string]interface{}{ + "methods": in["methods"], + "service": in["service"], + } +} + +func convertApikeysKeyRestrictionsApiTargetsList(i interface{}) (out []map[string]interface{}) { + if i == nil { + return nil + } + + for _, v := range i.([]interface{}) { + out = append(out, convertApikeysKeyRestrictionsApiTargets(v)) + } + return out +} + +func convertApikeysKeyRestrictionsBrowserKeyRestrictions(i interface{}) map[string]interface{} { + if i == nil { + return nil + } + in := i.(map[string]interface{}) + return map[string]interface{}{ + "allowedReferrers": in["allowed_referrers"], + } +} + +func convertApikeysKeyRestrictionsBrowserKeyRestrictionsList(i interface{}) (out []map[string]interface{}) { + if i == nil { + return nil + } + + for _, v := range i.([]interface{}) { + out = append(out, convertApikeysKeyRestrictionsBrowserKeyRestrictions(v)) + } + return out +} + +func convertApikeysKeyRestrictionsIosKeyRestrictions(i interface{}) map[string]interface{} { + if i == nil { + return nil + } + in := i.(map[string]interface{}) + return map[string]interface{}{ + "allowedBundleIds": in["allowed_bundle_ids"], + } +} + +func convertApikeysKeyRestrictionsIosKeyRestrictionsList(i interface{}) (out []map[string]interface{}) { + if i == nil { + return nil + } + + for _, v := range i.([]interface{}) { + out = append(out, convertApikeysKeyRestrictionsIosKeyRestrictions(v)) + } + return out +} + +func convertApikeysKeyRestrictionsServerKeyRestrictions(i interface{}) map[string]interface{} { + if i == nil { + return nil + } + in := i.(map[string]interface{}) + return map[string]interface{}{ + "allowedIps": in["allowed_ips"], + } +} + +func convertApikeysKeyRestrictionsServerKeyRestrictionsList(i interface{}) (out []map[string]interface{}) { + if i == nil { + return nil + } + + for _, v := range i.([]interface{}) { + out = append(out, convertApikeysKeyRestrictionsServerKeyRestrictions(v)) + } + return out +} + func convertAssuredWorkloadsWorkloadKmsSettings(i interface{}) map[string]interface{} { if i == nil { return nil