Skip to content

Commit

Permalink
Merge pull request inspec#155 from modular-magician/codegen-pr-1758
Browse files Browse the repository at this point in the history
Add pubsub subscription and topic iam policies, update example docs
  • Loading branch information
slevenick authored May 29, 2019
2 parents 68ff143 + cd72c2c commit 965231f
Show file tree
Hide file tree
Showing 5 changed files with 207 additions and 2 deletions.
7 changes: 5 additions & 2 deletions docs/resources/google_compute_subnetwork_iam_policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ describe google_compute_subnetwork_iam_policy(project: "project", region: "regio
it { should exist }
end
describe google_compute_subnetwork_iam_policy(project: "project", region: "region", name: "name").bindings do |binding|
its('role') { should_not eq 'roles/owner' }
google_compute_subnetwork_iam_policy(project: "project", region: "region", name: "name").bindings.each do |binding|
describe binding do
its('role') { should eq 'roles/editor'}
its('members') { should include 'user:[email protected]'}
end
end
```

Expand Down
42 changes: 42 additions & 0 deletions docs/resources/google_pubsub_subscription_iam_policy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
title: About the google_pubsub_subscription_iam_policy resource
platform: gcp
---

## Syntax
A `google_pubsub_subscription_iam_policy` is used to test a Google Subscription Iam Policy resource

## Examples
```
describe google_pubsub_subscription_iam_policy(project: "project", name: "name") do
it { should exist }
end
google_pubsub_subscription_iam_policy(project: "project", name: "name").bindings.each do |binding|
describe binding do
its('role') { should eq 'roles/editor'}
its('members') { should include 'user:[email protected]'}
end
end
```

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

* `bindings`: Associates a list of members to a role.

* `role`: Role that is assigned to members. For example, roles/viewer, roles/editor, or roles/owner.

* `members`: Specifies the identities requesting access for a Cloud Platform resource.

* `audit_configs`: Specifies cloud audit logging configuration for this policy.

* `service`: Specifies a service that will be enabled for audit logging. For example, `storage.googleapis.com`, `cloudsql.googleapis.com`. `allServices` is a special value that covers all services.

* `audit_log_configs`: The configuration for logging of each type of permission.



## GCP Permissions

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

## Syntax
A `google_pubsub_topic_iam_policy` is used to test a Google Topic Iam Policy resource

## Examples
```
describe google_pubsub_topic_iam_policy(project: "project", name: "name") do
it { should exist }
end
google_pubsub_topic_iam_policy(project: "project", name: "name").bindings.each do |binding|
describe binding do
its('role') { should eq 'roles/editor'}
its('members') { should include 'user:[email protected]'}
end
end
```

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

* `bindings`: Associates a list of members to a role.

* `role`: Role that is assigned to members. For example, roles/viewer, roles/editor, or roles/owner.

* `members`: Specifies the identities requesting access for a Cloud Platform resource.

* `audit_configs`: Specifies cloud audit logging configuration for this policy.

* `service`: Specifies a service that will be enabled for audit logging. For example, `storage.googleapis.com`, `cloudsql.googleapis.com`. `allServices` is a special value that covers all services.

* `audit_log_configs`: The configuration for logging of each type of permission.



## GCP Permissions

Ensure the [Cloud Pub/Sub API](https://console.cloud.google.com/apis/library/pubsub.googleapis.com/) is enabled for the current project.
59 changes: 59 additions & 0 deletions libraries/google_pubsub_subscription_iam_policy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
#
# ----------------------------------------------------------------------------
#
# 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'
require 'google/iam/property/iam_policy_audit_configs'
require 'google/iam/property/iam_policy_bindings'

# A provider to manage Cloud Pub/Sub IAM Policy resources.
class SubscriptionIamPolicy < GcpResourceBase
name 'google_pubsub_subscription_iam_policy'
desc 'Subscription Iam Policy'
supports platform: 'gcp'

attr_reader :params
attr_reader :bindings
attr_reader :audit_configs

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

def parse
@bindings = GoogleInSpec::Iam::Property::IamPolicyBindingsArray.parse(@fetched['bindings'], to_s)
@audit_configs = GoogleInSpec::Iam::Property::IamPolicyAuditConfigsArray.parse(@fetched['auditConfigs'], to_s)
end

def exists?
!@fetched.nil?
end

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

private

def product_url
'https://pubsub.googleapis.com/v1/'
end

def resource_base_url
'projects/{{project}}/subscriptions/{{name}}:getIamPolicy'
end
end
59 changes: 59 additions & 0 deletions libraries/google_pubsub_topic_iam_policy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
#
# ----------------------------------------------------------------------------
#
# 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'
require 'google/iam/property/iam_policy_audit_configs'
require 'google/iam/property/iam_policy_bindings'

# A provider to manage Cloud Pub/Sub IAM Policy resources.
class TopicIamPolicy < GcpResourceBase
name 'google_pubsub_topic_iam_policy'
desc 'Topic Iam Policy'
supports platform: 'gcp'

attr_reader :params
attr_reader :bindings
attr_reader :audit_configs

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

def parse
@bindings = GoogleInSpec::Iam::Property::IamPolicyBindingsArray.parse(@fetched['bindings'], to_s)
@audit_configs = GoogleInSpec::Iam::Property::IamPolicyAuditConfigsArray.parse(@fetched['auditConfigs'], to_s)
end

def exists?
!@fetched.nil?
end

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

private

def product_url
'https://pubsub.googleapis.com/v1/'
end

def resource_base_url
'projects/{{project}}/topics/{{name}}:getIamPolicy'
end
end

0 comments on commit 965231f

Please sign in to comment.