/
google_project_alert_policy.rb
78 lines (67 loc) · 2.39 KB
/
google_project_alert_policy.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# 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/monitoring/property/alertpolicy_conditions'
require 'google/monitoring/property/alertpolicy_creation_record'
require 'google/monitoring/property/alertpolicy_documentation'
# A provider to manage Cloud (Stackdriver) Monitoring resources.
class MonitoringAlertPolicy < GcpResourceBase
name 'google_project_alert_policy'
desc 'AlertPolicy'
supports platform: 'gcp'
attr_reader :params
attr_reader :name
attr_reader :display_name
attr_reader :combiner
attr_reader :creation_record
attr_reader :enabled
attr_reader :conditions
attr_reader :notification_channels
attr_reader :user_labels
attr_reader :documentation
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
@name = @fetched['name']
@display_name = @fetched['displayName']
@combiner = @fetched['combiner']
@creation_record = GoogleInSpec::Monitoring::Property::AlertPolicyCreationRecord.new(@fetched['creationRecord'], to_s)
@enabled = @fetched['enabled']
@conditions = GoogleInSpec::Monitoring::Property::AlertPolicyConditionsArray.parse(@fetched['conditions'], to_s)
@notification_channels = @fetched['notificationChannels']
@user_labels = @fetched['userLabels']
@documentation = GoogleInSpec::Monitoring::Property::AlertPolicyDocumentation.new(@fetched['documentation'], to_s)
end
def exists?
!@fetched.nil?
end
def to_s
"AlertPolicy #{@params[:name]}"
end
def enabled?
@enabled
end
private
def product_url(_ = nil)
'https://monitoring.googleapis.com/'
end
def resource_base_url
'v3/projects/{{project}}/alertPolicies/{{name}}'
end
end