From 6f8ccbf8b17909d762e7c4aca75954d82e061772 Mon Sep 17 00:00:00 2001 From: Alex Stephen Date: Thu, 30 May 2019 10:34:17 -0700 Subject: [PATCH] Change collection_url_response to a string (#1851) Merged PR #1851. --- api/resource.rb | 14 +- api/resource/response_list.rb | 37 ------ products/bigquery/api.yaml | 4 - products/cloudbuild/api.yaml | 2 - products/cloudbuild/inspec.yaml | 3 - products/cloudfunctions/api.yaml | 3 +- products/compute/api.yaml | 176 +++++++------------------ products/container/api.yaml | 4 - products/dns/api.yaml | 7 +- products/iam/api.yaml | 3 +- products/pubsub/api.yaml | 4 - products/redis/api.yaml | 2 - products/resourcemanager/api.yaml | 6 - products/sourcerepo/api.yaml | 3 +- products/spanner/api.yaml | 4 - products/sql/api.yaml | 3 + templates/ansible/facts.erb | 4 +- templates/inspec/plural_resource.erb | 2 +- templates/inspec/singular_resource.erb | 2 +- 19 files changed, 61 insertions(+), 222 deletions(-) delete mode 100644 api/resource/response_list.rb diff --git a/api/resource.rb b/api/resource.rb index a5d95f10302d..cc9256d4ffe5 100644 --- a/api/resource.rb +++ b/api/resource.rb @@ -15,7 +15,6 @@ require 'api/resource/iam_policy' require 'api/resource/nested_query' require 'api/resource/reference_links' -require 'api/resource/response_list' require 'google/string_utils' module Api @@ -82,10 +81,10 @@ module Properties # Collection / Identity URL Configuration # ==================== # - # [Optional] (Api::Resource::ResponseList) This is the type of response - # from the collection URL. It contains the name of the list of items - # within the json, as well as the type that this list should be. - attr_reader :collection_url_response + # [Optional] This is the name of the list of items + # within the collection (list) json. Will default to the + # camelcase pluralize name of the resource. + attr_reader :collection_url_key # [Optional] This is an array with items that uniquely identify the # resource. # This is useful in case an API returns a list result and we need @@ -148,8 +147,7 @@ def validate `has exactly one :identity property"' end - check :collection_url_response, default: Api::Resource::ResponseList.new, - type: Api::Resource::ResponseList + check :collection_url_key, default: @name.pluralize.camelize(:lower) check :create_verb, type: Symbol, default: :POST, allowed: %i[POST PUT] check :delete_verb, type: Symbol, default: :DELETE, allowed: %i[POST PUT PATCH DELETE] @@ -378,7 +376,7 @@ def to_s def to_json(opts = nil) # ignore fields that will contain references to parent resources ignored_fields = %i[@__product @__parent @__resource @api_name - @collection_url_response @properties @parameters] + @properties @parameters] json_out = {} instance_variables.each do |v| diff --git a/api/resource/response_list.rb b/api/resource/response_list.rb deleted file mode 100644 index 5f61642add87..000000000000 --- a/api/resource/response_list.rb +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright 2019 Google Inc. -# 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. - -require 'api/object' -require 'google/string_utils' - -module Api - # An object available in the product - class Resource < Api::Object::Named - # Represents a response from the API that returns a list of objects. - class ResponseList < Api::Object - attr_reader :kind - attr_reader :items - - def validate - super - - check :items, default: 'items', type: ::String, required: true - check :kind, type: ::String - end - - def kind? - !@kind.nil? - end - end - end -end diff --git a/products/bigquery/api.yaml b/products/bigquery/api.yaml index 0856c8911c2e..60b3561ff05a 100644 --- a/products/bigquery/api.yaml +++ b/products/bigquery/api.yaml @@ -32,8 +32,6 @@ objects: base_url: projects/{{project}}/datasets description: | Datasets allow you to organize and control access to your tables. - collection_url_response: !ruby/object:Api::Resource::ResponseList - items: 'datasets' properties: - !ruby/object:Api::Type::String name: 'name' @@ -153,8 +151,6 @@ objects: base_url: projects/{{project}}/datasets/{{dataset}}/tables description: | A Table that belongs to a Dataset - collection_url_response: !ruby/object:Api::Resource::ResponseList - items: 'tables' parameters: # TODO(alexstephen): Remove once we have support for placing # nested object fields in URL diff --git a/products/cloudbuild/api.yaml b/products/cloudbuild/api.yaml index 5dfa86f0ae39..5c9da4efebd5 100644 --- a/products/cloudbuild/api.yaml +++ b/products/cloudbuild/api.yaml @@ -34,8 +34,6 @@ objects: guides: 'Automating builds using build triggers': 'https://cloud.google.com/cloud-build/docs/running-builds/automate-builds' api: 'https://cloud.google.com/cloud-build/docs/api/reference/rest/' - collection_url_response: !ruby/object:Api::Resource::ResponseList - items: 'triggers' description: | Configuration for an automated build in response to source repository changes. properties: diff --git a/products/cloudbuild/inspec.yaml b/products/cloudbuild/inspec.yaml index e1f0f76b6039..63c176b61ec4 100644 --- a/products/cloudbuild/inspec.yaml +++ b/products/cloudbuild/inspec.yaml @@ -13,9 +13,6 @@ --- !ruby/object:Provider::Inspec::Config overrides: !ruby/object:Overrides::ResourceOverrides - Trigger: !ruby/object:Overrides::Inspec::ResourceOverride - collection_url_response: !ruby/object:Api::Resource::ResponseList - items: 'triggers' files: !ruby/object:Provider::Config::Files copy: 'Gemfile': 'provider/inspec/Gemfile' diff --git a/products/cloudfunctions/api.yaml b/products/cloudfunctions/api.yaml index 174ac6085250..e8a4273e7da9 100644 --- a/products/cloudfunctions/api.yaml +++ b/products/cloudfunctions/api.yaml @@ -31,6 +31,7 @@ objects: create_verb: :POST description: | A Cloud Function that contains user computation executed in response to an event. + collection_url_key: 'functions' properties: - !ruby/object:Api::Type::String name: 'name' @@ -152,5 +153,3 @@ objects: name: 'service' description: | The hostname of the service that should be observed. - collection_url_response: !ruby/object:Api::Resource::ResponseList - items: 'functions' \ No newline at end of file diff --git a/products/compute/api.yaml b/products/compute/api.yaml index 644291c17033..6b5870a86ea7 100644 --- a/products/compute/api.yaml +++ b/products/compute/api.yaml @@ -35,9 +35,7 @@ objects: name: 'Address' kind: 'compute#address' base_url: projects/{{project}}/regions/{{region}}/addresses - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#addressList' - items: 'items' + collection_url_key: 'items' has_self_link: true input: true description: | @@ -169,9 +167,7 @@ objects: kind: 'compute#autoscaler' base_url: projects/{{project}}/zones/{{zone}}/autoscalers update_url: projects/{{project}}/zones/{{zone}}/autoscalers?autoscaler={{name}} - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#autoscalerList' - items: 'items' + collection_url_key: 'items' has_self_link: true description: | Represents an Autoscaler resource. @@ -412,9 +408,7 @@ objects: name: 'BackendBucket' kind: 'compute#backendBucket' base_url: projects/{{project}}/global/backendBuckets - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#backendBucketLists' - items: 'items' + collection_url_key: 'items' has_self_link: true description: | Backend buckets allow you to use Google Cloud Storage buckets with HTTP(S) @@ -564,9 +558,7 @@ objects: name: 'BackendService' kind: 'compute#backendService' base_url: projects/{{project}}/global/backendServices - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#backendServicesList' - items: 'items' + collection_url_key: 'items' has_self_link: true description: | A Backend Service defines a group of virtual machines that will serve @@ -909,9 +901,7 @@ objects: name: 'RegionBackendService' kind: 'compute#backendService' base_url: projects/{{project}}/regions/{{region}}/backendServices - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#backendServicesList' - items: 'items' + collection_url_key: 'items' has_self_link: true description: | A Region Backend Service defines a regionally-scoped group of virtual @@ -1123,9 +1113,7 @@ objects: name: 'DiskType' kind: 'compute#diskType' base_url: projects/{{project}}/zones/{{zone}}/diskTypes - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#diskTypeList' - items: 'items' + collection_url_key: 'items' # TODO(nelsonjr): Search all documentation for references of using URL (like # the description below) and replace with the proper reference to the # corresponding type. @@ -1225,9 +1213,7 @@ objects: kind: 'compute#disk' input: true base_url: projects/{{project}}/zones/{{zone}}/disks - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#diskList' - items: 'items' + collection_url_key: 'items' has_self_link: true description: | Persistent disks are durable storage devices that function similarly to @@ -1512,9 +1498,7 @@ objects: name: 'Firewall' kind: 'compute#firewall' base_url: projects/{{project}}/global/firewalls - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#firewallList' - items: 'items' + collection_url_key: 'items' update_verb: :PATCH has_self_link: true references: !ruby/object:Api::Resource::ReferenceLinks @@ -1778,9 +1762,7 @@ objects: name: 'ForwardingRule' kind: 'compute#forwardingRule' base_url: projects/{{project}}/regions/{{region}}/forwardingRules - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#forwardingRuleList' - items: 'items' + collection_url_key: 'items' has_self_link: true description: | A ForwardingRule resource. A ForwardingRule resource specifies which pool @@ -2056,9 +2038,7 @@ objects: name: 'GlobalAddress' kind: 'compute#address' base_url: projects/{{project}}/global/addresses - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#addressList' - items: 'items' + collection_url_key: 'items' has_self_link: true description: | Represents a Global Address resource. Global addresses are used for @@ -2199,9 +2179,7 @@ objects: base_url: projects/{{project}}/global/forwardingRules input: true has_self_link: true - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#forwardingRulesList' - items: 'items' + collection_url_key: 'items' description: | Represents a GlobalForwardingRule resource. Global forwarding rules are used to forward traffic to the correct load balancer for HTTP load @@ -2383,9 +2361,7 @@ objects: name: 'HttpHealthCheck' kind: 'compute#httpHealthCheck' base_url: projects/{{project}}/global/httpHealthChecks - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#httpHealthCheckList' - items: 'items' + collection_url_key: 'items' has_self_link: true description: | An HttpHealthCheck resource. This resource defines a template for how @@ -2482,9 +2458,7 @@ objects: name: 'HttpsHealthCheck' kind: 'compute#httpsHealthCheck' base_url: projects/{{project}}/global/httpsHealthChecks - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#httpsHealthCheckList' - items: 'items' + collection_url_key: 'items' has_self_link: true description: | An HttpsHealthCheck resource. This resource defines a template for how @@ -2580,9 +2554,7 @@ objects: name: 'HealthCheck' kind: 'compute#healthCheck' base_url: projects/{{project}}/global/healthChecks - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#healthCheckList' - items: 'items' + collection_url_key: 'items' has_self_link: true references: !ruby/object:Api::Resource::ReferenceLinks guides: @@ -2854,9 +2826,7 @@ objects: kind: 'compute#instanceTemplate' input: true base_url: projects/{{project}}/global/instanceTemplates - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#instanceTemplatesListResponse' - items: 'items' + collection_url_key: 'items' has_self_link: true description: | Defines an Instance Template resource that provides configuration settings @@ -3332,9 +3302,7 @@ objects: name: 'License' kind: 'compute#license' base_url: /projects/{{project}}/global/licenses - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#TODO???' - items: 'items' + collection_url_key: 'items' readonly: true has_self_link: true description: | @@ -3360,9 +3328,7 @@ objects: base_url: projects/{{project}}/global/images input: true has_self_link: true - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#imageList' - items: 'items' + collection_url_key: 'items' references: !ruby/object:Api::Resource::ReferenceLinks guides: 'Official Documentation': 'https://cloud.google.com/compute/docs/images' @@ -3643,9 +3609,7 @@ objects: name: 'Instance' kind: 'compute#instance' base_url: projects/{{project}}/zones/{{zone}}/instances - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#instanceList' - items: 'items' + collection_url_key: 'items' input: true has_self_link: true description: | @@ -4154,9 +4118,7 @@ objects: name: 'InstanceGroup' kind: 'compute#instanceGroup' base_url: projects/{{project}}/zones/{{zone}}/instanceGroups - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#instanceGroupList' - items: 'items' + collection_url_key: 'items' has_self_link: true description: | Represents an Instance Group resource. Instance groups are self-managed @@ -4270,9 +4232,7 @@ objects: name: 'InstanceGroupManager' kind: 'compute#instanceGroupManager' base_url: projects/{{project}}/zones/{{zone}}/instanceGroupManagers - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#instanceGroupManagerList' - items: 'items' + collection_url_key: 'items' has_self_link: true description: | Creates a managed instance group using the information that you specify in @@ -4471,9 +4431,7 @@ objects: name: 'InterconnectAttachment' kind: 'compute#interconnectAttachment' base_url: 'projects/{{project}}/regions/{{region}}/interconnectAttachments' - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#interconnectAttachementList' - items: 'items' + collection_url_key: 'items' has_self_link: true input: true description: | @@ -4649,9 +4607,7 @@ objects: name: 'MachineType' kind: 'compute#machineType' base_url: projects/{{project}}/zones/{{zone}}/machineTypes - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#machineTypeList' - items: 'items' + collection_url_key: 'items' has_self_link: true readonly: true description: | @@ -4759,9 +4715,7 @@ objects: name: 'Network' kind: 'compute#network' base_url: projects/{{project}}/global/networks - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#networkList' - items: 'items' + collection_url_key: 'items' input: true has_self_link: true references: !ruby/object:Api::Resource::ReferenceLinks @@ -5164,9 +5118,7 @@ objects: name: 'Region' kind: 'compute#region' base_url: projects/{{project}}/regions - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#regionList' - items: 'items' + collection_url_key: 'items' has_self_link: true readonly: true description: | @@ -5272,9 +5224,7 @@ objects: kind: 'compute#autoscaler' base_url: projects/{{project}}/regions/{{region}}/autoscalers update_url: projects/{{project}}/regions/{{region}}/autoscalers?autoscaler={{name}} - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#autoscalerList' - items: 'items' + collection_url_key: 'items' has_self_link: true description: | Represents an Autoscaler resource. @@ -5516,9 +5466,7 @@ objects: name: 'RegionDiskType' kind: 'compute#diskType' base_url: projects/{{project}}/regions/{{region}}/diskTypes - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#diskTypeList' - items: 'items' + collection_url_key: 'items' description: | Represents a regional DiskType resource. A DiskType resource represents the type of disk to use, such as a pd-ssd or pd-standard. To reference a @@ -5607,9 +5555,7 @@ objects: kind: 'compute#disk' input: true base_url: projects/{{project}}/regions/{{region}}/disks - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#diskList' - items: 'items' + collection_url_key: 'items' has_self_link: true description: | Persistent disks are durable storage devices that function similarly to @@ -5846,9 +5792,7 @@ objects: name: 'Route' kind: 'compute#route' base_url: projects/{{project}}/global/routes - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#routeList' - items: 'items' + collection_url_key: 'items' input: true has_self_link: true description: | @@ -5989,9 +5933,7 @@ objects: name: 'Router' kind: 'compute#router' base_url: projects/{{project}}/regions/{{region}}/routers - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#routerList' - items: 'items' + collection_url_key: 'items' # Since Terraform has separate resources for router, router interface, and # router peer, calling PUT on the router will delete the interface and peer. # Use patch instead. @@ -6132,9 +6074,7 @@ objects: input: true base_url: projects/{{project}}/global/snapshots create_url: projects/{{project}}/zones/{{zone}}/disks/{{sourceDisk}}/createSnapshot - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#snapshotList' - items: 'items' + collection_url_key: 'items' has_self_link: true references: !ruby/object:Api::Resource::ReferenceLinks guides: @@ -6311,9 +6251,7 @@ objects: name: 'SslCertificate' kind: 'compute#sslCertificate' base_url: projects/{{project}}/global/sslCertificates - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#sslCertificateList' - items: 'items' + collection_url_key: 'items' references: !ruby/object:Api::Resource::ReferenceLinks guides: 'Official Documentation': 'https://cloud.google.com/load-balancing/docs/ssl-certificates' @@ -6383,9 +6321,7 @@ objects: kind: 'compute#sslCertificate' min_version: beta base_url: projects/{{project}}/global/sslCertificates - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#sslCertificateList' - items: 'items' + collection_url_key: 'items' references: !ruby/object:Api::Resource::ReferenceLinks guides: 'Official Documentation': 'https://cloud.google.com/load-balancing/docs/ssl-certificates' @@ -6479,9 +6415,7 @@ objects: name: 'SslPolicy' kind: 'compute#sslPolicy' base_url: projects/{{project}}/global/sslPolicies - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#sslPoliciesList' - items: 'items' + collection_url_key: 'items' update_verb: :PATCH has_self_link: true description: | @@ -6596,9 +6530,7 @@ objects: name: 'Subnetwork' kind: 'compute#subnetwork' base_url: projects/{{project}}/regions/{{region}}/subnetworks - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#subnetworkList' - items: 'items' + collection_url_key: 'items' input: true has_self_link: true description: | @@ -6808,9 +6740,7 @@ objects: name: 'TargetHttpProxy' kind: 'compute#targetHttpProxy' base_url: projects/{{project}}/global/targetHttpProxies - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#targetHttpProxyList' - items: 'items' + collection_url_key: 'items' has_self_link: true input: true description: | @@ -6876,9 +6806,7 @@ objects: name: 'TargetHttpsProxy' kind: 'compute#targetHttpsProxy' base_url: projects/{{project}}/global/targetHttpsProxies - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#targetHttpProxyList' - items: 'items' + collection_url_key: 'items' has_self_link: true input: true description: | @@ -7070,9 +6998,7 @@ objects: name: 'TargetPool' kind: 'compute#targetPool' base_url: projects/{{project}}/regions/{{region}}/targetPools - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#targetPoolList' - items: 'items' + collection_url_key: 'items' description: 'Represents a TargetPool resource, used for Load Balancing.' has_self_link: true references: !ruby/object:Api::Resource::ReferenceLinks @@ -7209,9 +7135,7 @@ objects: name: 'TargetSslProxy' kind: 'compute#targetSslProxy' base_url: projects/{{project}}/global/targetSslProxies - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#targetSslProxyList' - items: 'items' + collection_url_key: 'items' input: true has_self_link: true description: | @@ -7314,9 +7238,7 @@ objects: name: 'TargetTcpProxy' kind: 'compute#targetTcpProxy' base_url: projects/{{project}}/global/targetTcpProxies - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#targetTcpProxyList' - items: 'items' + collection_url_key: 'items' input: true has_self_link: true description: | @@ -7394,9 +7316,7 @@ objects: name: 'TargetVpnGateway' kind: 'compute#targetVpnGateway' base_url: projects/{{project}}/regions/{{region}}/targetVpnGateways - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#targetVpnGatewayList' - items: 'items' + collection_url_key: 'items' input: true has_self_link: true description: | @@ -7491,9 +7411,7 @@ objects: name: 'VpnGateway' kind: 'compute#vpnGateway' base_url: projects/{{project}}/regions/{{region}}/vpnGateways - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#vpnGatewayList' - items: 'items' + collection_url_key: 'items' input: true has_self_link: true min_version: beta @@ -7582,9 +7500,7 @@ objects: name: 'UrlMap' kind: 'compute#urlMap' base_url: projects/{{project}}/global/urlMaps - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#urlMapList' - items: 'items' + collection_url_key: 'items' has_self_link: true description: | UrlMaps are used to route requests to a backend service based on rules @@ -7748,9 +7664,7 @@ objects: description: 'VPN tunnel resource.' input: true base_url: projects/{{project}}/regions/{{region}}/vpnTunnels - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#vpnTunnelList' - items: 'items' + collection_url_key: 'items' has_self_link: true references: !ruby/object:Api::Resource::ReferenceLinks guides: @@ -7915,9 +7829,7 @@ objects: name: 'Zone' kind: 'compute#zone' base_url: projects/{{project}}/zones - collection_url_response: !ruby/object:Api::Resource::ResponseList - kind: 'compute#zoneList' - items: 'items' + collection_url_key: 'items' has_self_link: true readonly: true description: 'Represents a Zone resource.' diff --git a/products/container/api.yaml b/products/container/api.yaml index 2fe0867d344a..ce4f3a70467c 100644 --- a/products/container/api.yaml +++ b/products/container/api.yaml @@ -52,8 +52,6 @@ objects: name: 'Cluster' base_url: 'projects/{{project}}/locations/{{location}}/clusters' description: 'A Google Container Engine cluster.' - collection_url_response: !ruby/object:Api::Resource::ResponseList - items: 'clusters' parameters: - !ruby/object:Api::Type::String name: 'location' @@ -430,8 +428,6 @@ objects: set of Kubernetes labels applied to them, which may be used to reference them during pod scheduling. They may also be resized up or down, to accommodate the workload. - collection_url_response: !ruby/object:Api::Resource::ResponseList - items: 'nodePools' parameters: - !ruby/object:Api::Type::ResourceRef name: 'cluster' diff --git a/products/dns/api.yaml b/products/dns/api.yaml index 517d1ba4400f..f6badb3c740f 100644 --- a/products/dns/api.yaml +++ b/products/dns/api.yaml @@ -38,8 +38,6 @@ objects: A zone is a subtree of the DNS namespace under one administrative responsibility. A ManagedZone is a resource that represents a DNS zone hosted by the Cloud DNS service. - collection_url_response: !ruby/object:Api::Resource::ResponseList - items: 'managedZones' properties: - !ruby/object:Api::Type::String name: 'description' @@ -238,8 +236,6 @@ objects: description: | A policy is a collection of DNS rules applied to one or more Virtual Private Cloud resources. - collection_url_response: !ruby/object:Api::Resource::ResponseList - items: 'policies' properties: - !ruby/object:Api::Type::NestedObject name: 'alternativeNameServerConfig' @@ -386,8 +382,7 @@ objects: nested_query: !ruby/object:Api::Resource::NestedQuery kind: 'dns#resourceRecordSetsListResponse' keys: ['rrsets'] - collection_url_response: !ruby/object:Api::Resource::ResponseList - items: 'rrsets' + collection_url_key: 'rrsets' identity: - name - type diff --git a/products/iam/api.yaml b/products/iam/api.yaml index 0169d1bf2749..652a5b37e15a 100644 --- a/products/iam/api.yaml +++ b/products/iam/api.yaml @@ -33,8 +33,6 @@ objects: description: | A role in the Identity and Access Management API update_mask: true - collection_url_response: !ruby/object:Api::Resource::ResponseList - items: 'roles' properties: - !ruby/object:Api::Type::String name: 'name' @@ -69,6 +67,7 @@ objects: - !ruby/object:Api::Resource name: 'ServiceAccount' base_url: projects/{{project}}/serviceAccounts + collection_url_key: 'items' description: | A service account in the Identity and Access Management API. properties: diff --git a/products/pubsub/api.yaml b/products/pubsub/api.yaml index 6c24d8df1d61..64eca5760e8f 100644 --- a/products/pubsub/api.yaml +++ b/products/pubsub/api.yaml @@ -44,8 +44,6 @@ objects: name: 'labels' description: | A set of key/value label pairs to assign to this Topic. - collection_url_response: !ruby/object:Api::Resource::ResponseList - items: 'topics' references: !ruby/object:Api::Resource::ReferenceLinks guides: 'Managing Topics': @@ -61,8 +59,6 @@ objects: update_verb: :PATCH update_mask: true update_url: projects/{{project}}/subscriptions/{{name}} - collection_url_response: !ruby/object:Api::Resource::ResponseList - items: 'subscriptions' references: !ruby/object:Api::Resource::ReferenceLinks guides: 'Managing Subscriptions': diff --git a/products/redis/api.yaml b/products/redis/api.yaml index 838d9b180719..80970cd0baf8 100644 --- a/products/redis/api.yaml +++ b/products/redis/api.yaml @@ -50,8 +50,6 @@ objects: update_mask: true description: | A Google Cloud Redis instance. - collection_url_response: !ruby/object:Api::Resource::ResponseList - items: 'instances' references: !ruby/object:Api::Resource::ReferenceLinks guides: 'Official Documentation': diff --git a/products/resourcemanager/api.yaml b/products/resourcemanager/api.yaml index a7d211ffcd26..32726049d1b0 100644 --- a/products/resourcemanager/api.yaml +++ b/products/resourcemanager/api.yaml @@ -33,8 +33,6 @@ objects: description: | Represents a GCP Project. A project is a container for ACLs, APIs, App Engine Apps, VMs, and other Google Cloud Platform resources. - collection_url_response: !ruby/object:Api::Resource::ResponseList - items: 'projects' async: !ruby/object:Api::Async operation: !ruby/object:Api::Async::Operation kind: 'notinuse' @@ -179,8 +177,6 @@ objects: name: 'Folder' base_url: 'folders?parent={{parent}}' self_link: '{{name}}' - collection_url_response: !ruby/object:Api::Resource::ResponseList - items: 'folders' description: A Folder in an Organization's resource hierarchy, used to organize that Organization's resources. parameters: - !ruby/object:Api::Type::String @@ -224,8 +220,6 @@ objects: name: 'Organization' base_url: 'organizations' collection_url: organizations:search - collection_url_response: !ruby/object:Api::Resource::ResponseList - items: 'organizations' description: A Folder in an Organization's resource hierarchy, used to organize that Organization's resources. properties: - !ruby/object:Api::Type::String diff --git a/products/sourcerepo/api.yaml b/products/sourcerepo/api.yaml index 3967a49f4a04..4ebc4ac03528 100644 --- a/products/sourcerepo/api.yaml +++ b/products/sourcerepo/api.yaml @@ -36,8 +36,7 @@ objects: guides: 'Official Documentation': 'https://cloud.google.com/source-repositories/' api: 'https://cloud.google.com/source-repositories/docs/reference/rest/v1/projects.repos' - collection_url_response: !ruby/object:Api::Resource::ResponseList - items: 'repos' + collection_url_key: 'repos' description: | A repository (or repo) is a Git repository storing versioned source content. properties: diff --git a/products/spanner/api.yaml b/products/spanner/api.yaml index 467d060d8469..3f9324227ae3 100644 --- a/products/spanner/api.yaml +++ b/products/spanner/api.yaml @@ -54,8 +54,6 @@ objects: guides: 'Official Documentation': 'https://cloud.google.com/spanner/' api: 'https://cloud.google.com/spanner/docs/reference/rest/v1/projects.instances' - collection_url_response: !ruby/object:Api::Resource::ResponseList - items: 'instances' async: !ruby/object:Api::Async operation: !ruby/object:Api::Async::Operation path: 'name' @@ -126,8 +124,6 @@ objects: description: | A Cloud Spanner Database which is hosted on a Spanner instance. input: true - collection_url_response: !ruby/object:Api::Resource::ResponseList - items: 'databases' references: !ruby/object:Api::Resource::ReferenceLinks guides: 'Official Documentation': 'https://cloud.google.com/spanner/' diff --git a/products/sql/api.yaml b/products/sql/api.yaml index 49d097ba41af..15bd0e7e1925 100644 --- a/products/sql/api.yaml +++ b/products/sql/api.yaml @@ -56,6 +56,7 @@ objects: Represents a Cloud SQL instance. Cloud SQL instances are SQL databases hosted in Google's cloud. The Instances resource provides methods for common configuration and management tasks. + collection_url_key: 'items' properties: - !ruby/object:Api::Type::Enum name: 'backendType' @@ -382,6 +383,7 @@ objects: kind: 'sql#database' base_url: projects/{{project}}/instances/{{instance}}/databases has_self_link: true + collection_url_key: 'items' description: | Represents a SQL database inside the Cloud SQL instance, hosted in Google's cloud. @@ -415,6 +417,7 @@ objects: nested_query: !ruby/object:Api::Resource::NestedQuery kind: 'sql#usersList' keys: ['items'] + collection_url_key: 'items' identity: - name - host diff --git a/templates/ansible/facts.erb b/templates/ansible/facts.erb index db3e0381ace5..e3968dcf1e36 100644 --- a/templates/ansible/facts.erb +++ b/templates/ansible/facts.erb @@ -102,8 +102,8 @@ def main(): end -%> items = <%= method_call('fetch_list', ['module', 'collection(module)', query_param]) %> - if items.get(<%= quote_string(object.collection_url_response.items) -%>): - items = items.get(<%= quote_string(object.collection_url_response.items) -%>) + if items.get(<%= quote_string(object.collection_url_key) -%>): + items = items.get(<%= quote_string(object.collection_url_key) -%>) else: items = [] return_value = { diff --git a/templates/inspec/plural_resource.erb b/templates/inspec/plural_resource.erb index 065e39a94ba3..236912eea8d9 100644 --- a/templates/inspec/plural_resource.erb +++ b/templates/inspec/plural_resource.erb @@ -36,7 +36,7 @@ name = "google_#{product_ns.downcase}_#{object.name.underscore}" filter_table_config.connect(self, :table) <% -link_query_items = object&.nested_query&.keys&.first || object.collection_url_response.items +link_query_items = object&.nested_query&.keys&.first || object.collection_url_key -%> def initialize(params = {}) super(params.merge({ use_http_transport: true })) diff --git a/templates/inspec/singular_resource.erb b/templates/inspec/singular_resource.erb index a665d314e432..064a474e7f25 100644 --- a/templates/inspec/singular_resource.erb +++ b/templates/inspec/singular_resource.erb @@ -60,7 +60,7 @@ class <%= object.name -%> < GcpResourceBase end def collection_item - '<%= object.collection_url_response.items -%>' + '<%= object.collection_url_key -%>' end def unwrap(fetched, params)