Skip to content

Commit

Permalink
Merge pull request #260 from inspec/CHEF-12238-V2-MAGIC-MODULE-monito…
Browse files Browse the repository at this point in the history
…ring_v3-Projects__group

CHEF-12238-V2-MAGIC-MODULE-monitoring_v3-Projects__group - Resource Implementation
  • Loading branch information
balasubramanian-s authored Oct 17, 2024
2 parents 92813bf + 98fdafc commit 802d8ee
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 1 deletion.
106 changes: 106 additions & 0 deletions mmv1/products/monitoring/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2114,3 +2114,109 @@ objects:
This field allows time series to be associated with the intersection of this metric
type and the monitored resource types in this list.
item_type: Api::Type::String



- !ruby/object:Api::Resource
name: ProjectGroup
base_url: '{{+name}}/groups'
self_link: '{{+name}}'
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'Official Documentation':
api: 'https://cloud.google.com/monitoring/docs'
async: !ruby/object:Api::OpAsync
operation: !ruby/object:Api::OpAsync::Operation
path: 'name'
base_url: '{op_id}'
wait_ms: 1000
result: !ruby/object:Api::OpAsync::Result
path: 'response'
resource_inside_response: true
status: !ruby/object:Api::OpAsync::Status
path: 'done'
complete: True
allowed:
- True
- False
error: !ruby/object:Api::OpAsync::Error
path: 'error'
message: 'message'
description: |-
The description of a dynamic collection of monitored resources. Each group has a filter that is matched against monitored resources and their associated metadata. If a group's filter matches an available monitored resource, then that resource is a member of that group. Groups can contain any number of monitored resources, and each monitored resource can be a member of any number of groups.Groups can be nested in parent-child hierarchies. The parentName field identifies an optional parent for each group. If a group has a parent, then the only monitored resources available to be matched by the group's filter are the resources contained in the parent group. In other words, a group contains the monitored resources that match its filter and the filters of all the group's ancestors. A group without a parent can contain any monitored resource.For example, consider an infrastructure running a set of instances with two user-defined tags: "environment" and "role". A parent group has a filter, environment="production". A child of that parent group has a filter, role="transcoder". The parent group contains all instances in the production environment, regardless of their roles. The child group contains instances that have the transcoder role and are in the production environment.The monitored resources contained in a group can change at any moment, depending on what resources exist and what filters are associated with the group and its ancestors.
properties:

- !ruby/object:Api::Type::String
name: 'name'
description: |
Output only. The name of this group. The format is: projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] When creating a group, this field is ignored and a new name is created consisting of the project specified in the call to CreateGroup and a unique [GROUP_ID] that is generated automatically.
- !ruby/object:Api::Type::String
name: 'displayName'
description: |
A user-assigned name for this group, used only for display purposes.
- !ruby/object:Api::Type::String
name: 'parentName'
description: |
The name of the group's parent, if it has one. The format is: projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] For groups with no parent, parent_name is the empty string, "".
- !ruby/object:Api::Type::String
name: 'filter'
description: |
The filter used to determine which monitored resources belong to this group.
- !ruby/object:Api::Type::Boolean
name: 'isCluster'
description: |
If true, the members of this group are considered to be a cluster. The system can perform additional analysis on groups that are clusters.



- !ruby/object:Api::Resource
name: ProjectGroup
base_url: '{{+name}}/groups'
self_link: '{{+name}}'
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'Official Documentation':
api: 'https://cloud.google.com/monitoring/docs'
async: !ruby/object:Api::OpAsync
operation: !ruby/object:Api::OpAsync::Operation
path: 'name'
base_url: '{op_id}'
wait_ms: 1000
result: !ruby/object:Api::OpAsync::Result
path: 'response'
resource_inside_response: true
status: !ruby/object:Api::OpAsync::Status
path: 'done'
complete: True
allowed:
- True
- False
error: !ruby/object:Api::OpAsync::Error
path: 'error'
message: 'message'
description: |-
The description of a dynamic collection of monitored resources. Each group has a filter that is matched against monitored resources and their associated metadata. If a group's filter matches an available monitored resource, then that resource is a member of that group. Groups can contain any number of monitored resources, and each monitored resource can be a member of any number of groups.Groups can be nested in parent-child hierarchies. The parentName field identifies an optional parent for each group. If a group has a parent, then the only monitored resources available to be matched by the group's filter are the resources contained in the parent group. In other words, a group contains the monitored resources that match its filter and the filters of all the group's ancestors. A group without a parent can contain any monitored resource.For example, consider an infrastructure running a set of instances with two user-defined tags: "environment" and "role". A parent group has a filter, environment="production". A child of that parent group has a filter, role="transcoder". The parent group contains all instances in the production environment, regardless of their roles. The child group contains instances that have the transcoder role and are in the production environment.The monitored resources contained in a group can change at any moment, depending on what resources exist and what filters are associated with the group and its ancestors.
properties:

- !ruby/object:Api::Type::String
name: 'name'
description: |
Output only. The name of this group. The format is: projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] When creating a group, this field is ignored and a new name is created consisting of the project specified in the call to CreateGroup and a unique [GROUP_ID] that is generated automatically.
- !ruby/object:Api::Type::String
name: 'displayName'
description: |
A user-assigned name for this group, used only for display purposes.
- !ruby/object:Api::Type::String
name: 'parentName'
description: |
The name of the group's parent, if it has one. The format is: projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] For groups with no parent, parent_name is the empty string, "".
- !ruby/object:Api::Type::String
name: 'filter'
description: |
The filter used to determine which monitored resources belong to this group.
- !ruby/object:Api::Type::Boolean
name: 'isCluster'
description: |
If true, the members of this group are considered to be a cluster. The system can perform additional analysis on groups that are clusters.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%>
<% project_group = grab_attributes(pwd)['project_group'] -%>
describe google_monitoring_project_group(name: <%= doc_generation ? "' #{project_group['name']}'":"project_group['name']" -%>) do
it { should exist }
its('name') { should cmp <%= doc_generation ? "'#{project_group['name']}'" : "project_group['name']" -%> }
its('display_name') { should cmp <%= doc_generation ? "'#{project_group['display_name']}'" : "project_group['display_name']" -%> }
its('parent_name') { should cmp <%= doc_generation ? "'#{project_group['parent_name']}'" : "project_group['parent_name']" -%> }
its('filter') { should cmp <%= doc_generation ? "'#{project_group['filter']}'" : "project_group['filter']" -%> }

end

describe google_monitoring_project_group(name: "does_not_exit") do
it { should_not exist }
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
gcp_project_id = input(:gcp_project_id, value: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.')

project_group = input('project_group', value: <%= JSON.pretty_generate(grab_attributes(pwd)['project_group']) -%>, description: 'project_group description')
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%>
<% project_group = grab_attributes(pwd)['project_group'] -%>
describe google_monitoring_project_groups(name: <%= doc_generation ? "' #{project_group['name']}'":"project_group['name']" -%>) do
it { should exist }
end
Original file line number Diff line number Diff line change
Expand Up @@ -1327,4 +1327,9 @@ batch:
state_message : "value_statemessage"
state_time : "value_statetime"
creator : "value_creator"
operation : "value_operation"
operation : "value_operation"
project_group:
name : "value_name"
display_name : "value_displayname"
parent_name : "value_parentname"
filter : "value_filter"

0 comments on commit 802d8ee

Please sign in to comment.