diff --git a/api/async.rb b/api/async.rb index d4d85c2cf715..b85c0ce5fc23 100644 --- a/api/async.rb +++ b/api/async.rb @@ -42,7 +42,7 @@ class Operation < Api::Object def validate super - check :kind, type: String, required: true + check :kind, type: String check :path, type: String, required: true check :base_url, type: String, required: true check :wait_ms, type: Integer, required: true diff --git a/build/ansible b/build/ansible index e78303e59160..c26f617b6be7 160000 --- a/build/ansible +++ b/build/ansible @@ -1 +1 @@ -Subproject commit e78303e59160b6314f784d7d19c1986c7a6a2acd +Subproject commit c26f617b6be7525143edb242b6ca7e21c2209a4b diff --git a/products/redis/ansible.yaml b/products/redis/ansible.yaml new file mode 100644 index 000000000000..696619ed256b --- /dev/null +++ b/products/redis/ansible.yaml @@ -0,0 +1,40 @@ +# Copyright 2017 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. + +--- !ruby/object:Provider::Ansible::Config +manifest: !ruby/object:Provider::Ansible::Manifest + metadata_version: '1.1' + status: + - preview + supported_by: 'community' + requirements: + - python >= 2.6 + - requests >= 2.18.4 + - google-auth >= 1.3.0 + version_added: '2.8' + author: Google Inc. (@googlecloudplatform) +# This is where custom code would be defined eventually. +datasources: !ruby/object:Overrides::ResourceOverrides + Instance: !ruby/object:Overrides::Ansible::ResourceOverride + version_added: '2.8' + base_url: projects/{{project}}/locations/{{region}}/instances + facts: !ruby/object:Provider::Ansible::FactsOverride + has_filters: false +overrides: !ruby/object:Overrides::ResourceOverrides + Instance: !ruby/object:Overrides::Ansible::ResourceOverride + # TODO(alexstephen): Create update masks and get Redis update support working + input: true + version_added: '2.8' +files: !ruby/object:Provider::Config::Files + compile: +<%= lines(indent(compile('provider/ansible/product~compile.yaml'), 4)) -%> diff --git a/products/redis/api.yaml b/products/redis/api.yaml index c3bd9597aa0a..52335a5de076 100644 --- a/products/redis/api.yaml +++ b/products/redis/api.yaml @@ -33,19 +33,34 @@ objects: update_verb: :PATCH 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': 'https://cloud.google.com/memorystore/docs/redis/' api: 'https://cloud.google.com/memorystore/docs/redis/reference/rest/' -<%= - # Cloud Redis takes a fair bit of time to provision/delete, try six minutes. - indent(compile_file({timeouts: { - insert_sec: 6 * 60, - update_sec: 6 * 60, - delete_sec: 6 * 60 }}, - 'templates/regional_async.yaml.erb'), 4) -%> + async: !ruby/object:Api::Async + operation: !ruby/object:Api::Async::Operation + path: 'name' + base_url: '{{op_id}}' + wait_ms: 1000 + timeouts: !ruby/object:Api::Timeouts + insert_sec: 360 + update_sec: 360 + delete_sec: 360 + result: !ruby/object:Api::Async::Result + path: 'response' + resource_inside_response: true + status: !ruby/object:Api::Async::Status + path: 'done' + complete: true + allowed: + - true + - false + error: !ruby/object:Api::Async::Error + path: 'error' + message: 'message' parameters: - !ruby/object:Api::Type::String # TODO: resourceref? name: 'region' diff --git a/products/redis/examples/ansible/instance.yaml b/products/redis/examples/ansible/instance.yaml new file mode 100644 index 000000000000..82f041d3405b --- /dev/null +++ b/products/redis/examples/ansible/instance.yaml @@ -0,0 +1,40 @@ +# Copyright 2018 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. + +--- !ruby/object:Provider::Ansible::Example +dependencies: + - !ruby/object:Provider::Ansible::Task + name: gcp_compute_network + register: network + code: + name: <%= dependency_name('network', 'instance') %> + project: <%= ctx[:project] %> + auth_kind: <%= ctx[:auth_kind] %> + service_account_file: <%= ctx[:service_account_file] %> +task: !ruby/object:Provider::Ansible::Task + name: gcp_redis_instance + code: + name: "instance37" + tier: "STANDARD_HA" + memory_size_gb: 1 + region: 'us-central1' + location_id: 'us-central1-a' + redis_version: "REDIS_3_2" + display_name: "Ansible Test Instance" + reserved_ip_range: "192.168.0.0/29" + labels: + my_key: my_val + other_key: other_val + project: <%= ctx[:project] %> + auth_kind: <%= ctx[:auth_kind] %> + service_account_file: <%= ctx[:service_account_file] %> diff --git a/templates/ansible/async.erb b/templates/ansible/async.erb index c6d057e3b9b4..a68e030a167f 100644 --- a/templates/ansible/async.erb +++ b/templates/ansible/async.erb @@ -46,7 +46,7 @@ def wait_for_completion(status, op_result, module): op_id = navigate_hash(op_result, <%= op_path -%>) op_uri = async_op_url(module, {'op_id': op_id}) <% if object.async.status.complete == true -%> - if not status: + while not status: <% else -%> while status != <%= python_literal(object.async.status.complete) -%>: <% end -%> diff --git a/templates/ansible/facts.erb b/templates/ansible/facts.erb index fb11e9045416..b8199d54ba8c 100644 --- a/templates/ansible/facts.erb +++ b/templates/ansible/facts.erb @@ -113,11 +113,7 @@ def main(): module.exit_json(**return_value) -<% if object.collection -%> -<%= lines(emit_link('collection', build_url(object.collection), object)) -%> -<% else # object.collection -%> <%= lines(emit_link('collection', build_url(object.collection_url), object)) -%> -<% end # object.collection -%> <%= method_decl('fetch_list', ['module', 'link', ('query' if object.facts.has_filters)]) %> diff --git a/templates/ansible/resource.erb b/templates/ansible/resource.erb index 35300f4f2750..36297c4b2418 100644 --- a/templates/ansible/resource.erb +++ b/templates/ansible/resource.erb @@ -277,7 +277,7 @@ def resource_to_request(module): properties_in_request = [ object&.parameters&.select { |p| p.input }, object.properties.reject(&:output) - ].flatten.compact + ].flatten.compact.reject(&:url_param_only) -%> <% request_hash = {