Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CHEF-7361-MAGIC-MODULE-apigee-Organizations__apis__revision - Resource Implementation #559

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions docs/resources/google_apigee_organization_api_revision.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
title: About the google_apigee_organization_api_revision resource
platform: gcp
---

## Syntax
A `google_apigee_organization_api_revision` is used to test a Google OrganizationApiRevision resource

## Examples
```
describe google_apigee_organization_api_revision(name: ' value_name') do
it { should exist }
its('content_type') { should cmp 'value_contenttype' }
its('data') { should cmp 'value_data' }

end

describe google_apigee_organization_api_revision(name: "does_not_exit") do
it { should_not exist }
end
```

## Properties
Properties that can be accessed from the `google_apigee_organization_api_revision` resource:


* `extensions`: Application specific response metadata. Must be set in the first response for streaming APIs.

* `content_type`: The HTTP Content-Type header value specifying the content type of the body.

* `data`: The HTTP request/response body as raw binary.


## GCP Permissions

Ensure the [Apigee API](https://console.cloud.google.com/apis/library/apigee.googleapis.com/) is enabled for the current project.
30 changes: 30 additions & 0 deletions docs/resources/google_apigee_organization_api_revisions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
title: About the google_apigee_organization_api_revisions resource
platform: gcp
---

## Syntax
A `google_apigee_organization_api_revisions` is used to test a Google OrganizationApiRevision resource

## Examples
```
describe google_apigee_organization_api_revisions() do
it { should exist }
end
```

## Properties
Properties that can be accessed from the `google_apigee_organization_api_revisions` resource:

See [google_apigee_organization_api_revision.md](google_apigee_organization_api_revision.md) for more detailed information
* `extensions`: an array of `google_apigee_organization_api_revision` extensions
* `content_types`: an array of `google_apigee_organization_api_revision` content_type
* `data`: an array of `google_apigee_organization_api_revision` data

## Filter Criteria
This resource supports all of the above properties as filter criteria, which can be used
with `where` as a block or a method.

## GCP Permissions

Ensure the [Apigee API](https://console.cloud.google.com/apis/library/apigee.googleapis.com/) is enabled for the current project.
3 changes: 3 additions & 0 deletions libraries/gcp_backend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ def next_page(uri, request_type, token = nil)
request_type,
)
result = return_if_object(get_request.send)
if result.is_a?(Array)
return result
end
next_page_token = result['nextPageToken']
return [result] if next_page_token.nil?

Expand Down
73 changes: 73 additions & 0 deletions libraries/google_apigee_organization_api_revision.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** Type: MMv1 ***
#
# ----------------------------------------------------------------------------
#
# 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 README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
require 'gcp_backend'

# A provider to manage Apigee resources.
class ApigeeOrganizationApiRevision < GcpResourceBase
name 'google_apigee_organization_api_revision'
desc 'OrganizationApiRevision'
supports platform: 'gcp'

attr_reader :params
attr_reader :description
attr_reader :created_at
attr_reader :configuration_version
attr_reader :policies
attr_reader :entity_meta_data_as_properties
attr_reader :type
attr_reader :proxies
attr_reader :revision
attr_reader :name
attr_reader :last_modified_at

def initialize(params)
super(params.merge({ use_http_transport: true }))
@params = params
@fetched = @connection.fetch(product_url(params[:beta]), resource_base_url, params, 'Get')
parse unless @fetched.nil?
end

def parse
@policies = @fetched['policies']
@configuration_version = @fetched['configurationVersion']
@created_at = @fetched['createdAt']
@description = @fetched['description']
@entity_meta_data_as_properties = @fetched['entityMetaDataAsProperties']
@last_modified_at = @fetched['lastModifiedAt']
@name = @fetched['name']
@revision = @fetched['revision']
@proxies = @fetched['proxies']
@type = @fetched['type']
end

def exists?
[email protected]?
end

def to_s
"OrganizationApiRevision #{@params[:name]}"
end

private

def product_url(_ = nil)
'https://apigee.googleapis.com/v1/'
end

def resource_base_url
'{{name}}'
end
end
69 changes: 69 additions & 0 deletions libraries/google_apigee_organization_api_revisions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** Type: MMv1 ***
#
# ----------------------------------------------------------------------------
#
# 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 README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
require 'gcp_backend'
class ApigeeOrganizationApiRevisions < GcpResourceBase
name 'google_apigee_organization_api_revisions'
desc 'OrganizationApiRevision plural resource'
supports platform: 'gcp'

attr_reader :table

filter_table_config = FilterTable.create

filter_table_config.add(:extensions, field: :extensions)
filter_table_config.add(:content_types, field: :content_type)
filter_table_config.add(:data, field: :data)

filter_table_config.connect(self, :table)

def initialize(params = {})
super(params.merge({ use_http_transport: true }))
@params = params
@table = fetch_wrapped_resource('organizationApiRevisions')
end

def fetch_wrapped_resource(wrap_path)
# fetch_resource returns an array of responses (to handle pagination)
@connection.fetch_all(product_url, resource_base_url, @params, 'Get')
end

def revisions
@table
end
def transform(key, value)
return transformers[key].call(value) if transformers.key?(key)

[key.to_sym, value]
end

def transformers
{
'extensions' => ->(obj) { [:extensions, obj['extensions']] },
'contentType' => ->(obj) { [:content_type, obj['contentType']] },
'data' => ->(obj) { [:data, obj['data']] },
}
end

private

def product_url(_ = nil)
'https://apigee.googleapis.com/v1/'
end

def resource_base_url
'{{parent}}/revisions'
end
end
1 change: 0 additions & 1 deletion libraries/google_compute_regions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def fetch_wrapped_resource(wrap_path)
converted.push(hash_with_symbols)
end
end

converted
end

Expand Down
7 changes: 7 additions & 0 deletions test/integration/configuration/mm-attributes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -640,3 +640,10 @@ crypto_key_version:
key_ring: "gcp-inspec-kms-key-ring"
crypto_key: "gcp-inspec-kms-crypto-key-policy"
region: "us-central-1"

organization_api_revision:
name: "organizations/ppradhan/apis/helloworld/revisions/1"
parent: "organizations/ppradhan/apis/helloworld"
content_type: "Application"
revision: 1
api: "helloworld"
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** Type: MMv1 ***
#
# ----------------------------------------------------------------------------
#
# 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 README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------

title 'Test GCP google_apigee_organization_api_revision resource.'

gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.')

organization_api_revision = input('organization_api_revision', value: {
"name": "organizations/{organization}/apis/{api}/revisions/{revision}",
"content_type": "Application",
"data": "value_data",
"revision": 1,
}, description: 'organization_api_revision description')
control 'google_apigee_organization_api_revision-1.0' do
impact 1.0
title 'google_apigee_organization_api_revision resource test'

describe google_apigee_organization_api_revision(name: organization_api_revision['name']) do
it { should exist }
its('type') { should cmp organization_api_revision['content_type'] }
its('revision') { should cmp organization_api_revision['revision'] }
end

describe google_apigee_organization_api_revision(name: "does_not_exit") do
it { should_not exist }
end
end

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** Type: MMv1 ***
#
# ----------------------------------------------------------------------------
#
# 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 README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------

# title 'Test GCP google_apigee_organization_api_revisions resource.'
#
gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.')

organization_api_revision = input('organization_api_revision', value: {
"parent": "organizations/ppradhan/apis/helloworld",
"name": "organizations/{organization}/apis/{api}/revisions/{revision}",
"content_type": "Application",
"data": "value_data",
"revision": 1,
"api": "helloworld"
}, description: 'organization_api_revision description')

control 'google_apigee_organization_api_revisions-1.0' do
impact 1.0
title 'google_apigee_organization_api_revisions resource test'

describe google_apigee_organization_api_revisions(parent: organization_api_revision['parent']) do
it { should exist }
its('revisions') { should include "1" }
end

google_apigee_organization_api_revisions(parent: organization_api_revision['parent']).revisions.each do |rev|
describe google_apigee_organization_api_revision(name: "organizations/#{gcp_project_id}/apis/#{api}/revisions/#{rev}") do
it { should exist }
its('type') { should cmp organization_api_revision['content_type'] }
its('revision') { should cmp organization_api_revision['revision'] }
end
end
end