Skip to content

Commit

Permalink
Change collection_url_response to a string (#1851)
Browse files Browse the repository at this point in the history
Merged PR #1851.
  • Loading branch information
rambleraptor authored and modular-magician committed May 30, 2019
1 parent b2ce7a9 commit 6f8ccbf
Show file tree
Hide file tree
Showing 19 changed files with 61 additions and 222 deletions.
14 changes: 6 additions & 8 deletions api/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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|
Expand Down
37 changes: 0 additions & 37 deletions api/resource/response_list.rb

This file was deleted.

4 changes: 0 additions & 4 deletions products/bigquery/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions products/cloudbuild/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 0 additions & 3 deletions products/cloudbuild/inspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
3 changes: 1 addition & 2 deletions products/cloudfunctions/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Loading

0 comments on commit 6f8ccbf

Please sign in to comment.