azure_mgmt_monitor 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/lib/azure_mgmt_monitor.rb +5 -0
  4. data/lib/generated/azure_mgmt_monitor.rb +96 -0
  5. data/lib/generated/azure_mgmt_monitor/action_groups.rb +579 -0
  6. data/lib/generated/azure_mgmt_monitor/activity_log_alerts.rb +593 -0
  7. data/lib/generated/azure_mgmt_monitor/alert_rule_incidents.rb +211 -0
  8. data/lib/generated/azure_mgmt_monitor/alert_rules.rb +510 -0
  9. data/lib/generated/azure_mgmt_monitor/autoscale_settings.rb +618 -0
  10. data/lib/generated/azure_mgmt_monitor/log_profiles.rb +477 -0
  11. data/lib/generated/azure_mgmt_monitor/models/action_group_list.rb +63 -0
  12. data/lib/generated/azure_mgmt_monitor/models/action_group_resource.rb +164 -0
  13. data/lib/generated/azure_mgmt_monitor/models/activity_log_alert_action_group.rb +65 -0
  14. data/lib/generated/azure_mgmt_monitor/models/activity_log_alert_action_list.rb +54 -0
  15. data/lib/generated/azure_mgmt_monitor/models/activity_log_alert_all_of_condition.rb +55 -0
  16. data/lib/generated/azure_mgmt_monitor/models/activity_log_alert_leaf_condition.rb +61 -0
  17. data/lib/generated/azure_mgmt_monitor/models/activity_log_alert_list.rb +64 -0
  18. data/lib/generated/azure_mgmt_monitor/models/activity_log_alert_patch_body.rb +65 -0
  19. data/lib/generated/azure_mgmt_monitor/models/activity_log_alert_resource.rb +147 -0
  20. data/lib/generated/azure_mgmt_monitor/models/alert_rule_resource.rb +159 -0
  21. data/lib/generated/azure_mgmt_monitor/models/alert_rule_resource_collection.rb +54 -0
  22. data/lib/generated/azure_mgmt_monitor/models/alert_rule_resource_patch.rb +131 -0
  23. data/lib/generated/azure_mgmt_monitor/models/autoscale_notification.rb +78 -0
  24. data/lib/generated/azure_mgmt_monitor/models/autoscale_profile.rb +101 -0
  25. data/lib/generated/azure_mgmt_monitor/models/autoscale_setting_resource.rb +155 -0
  26. data/lib/generated/azure_mgmt_monitor/models/autoscale_setting_resource_collection.rb +95 -0
  27. data/lib/generated/azure_mgmt_monitor/models/autoscale_setting_resource_patch.rb +127 -0
  28. data/lib/generated/azure_mgmt_monitor/models/comparison_operation_type.rb +20 -0
  29. data/lib/generated/azure_mgmt_monitor/models/condition_operator.rb +18 -0
  30. data/lib/generated/azure_mgmt_monitor/models/email_notification.rb +75 -0
  31. data/lib/generated/azure_mgmt_monitor/models/email_receiver.rb +69 -0
  32. data/lib/generated/azure_mgmt_monitor/models/enable_request.rb +45 -0
  33. data/lib/generated/azure_mgmt_monitor/models/error_response.rb +55 -0
  34. data/lib/generated/azure_mgmt_monitor/models/incident.rb +93 -0
  35. data/lib/generated/azure_mgmt_monitor/models/incident_list_result.rb +53 -0
  36. data/lib/generated/azure_mgmt_monitor/models/location_threshold_rule_condition.rb +85 -0
  37. data/lib/generated/azure_mgmt_monitor/models/log_profile_collection.rb +53 -0
  38. data/lib/generated/azure_mgmt_monitor/models/log_profile_resource.rb +154 -0
  39. data/lib/generated/azure_mgmt_monitor/models/log_profile_resource_patch.rb +126 -0
  40. data/lib/generated/azure_mgmt_monitor/models/log_settings.rb +70 -0
  41. data/lib/generated/azure_mgmt_monitor/models/management_event_aggregation_condition.rb +70 -0
  42. data/lib/generated/azure_mgmt_monitor/models/management_event_rule_condition.rb +73 -0
  43. data/lib/generated/azure_mgmt_monitor/models/metric_settings.rb +67 -0
  44. data/lib/generated/azure_mgmt_monitor/models/metric_statistic_type.rb +18 -0
  45. data/lib/generated/azure_mgmt_monitor/models/metric_trigger.rb +134 -0
  46. data/lib/generated/azure_mgmt_monitor/models/receiver_status.rb +17 -0
  47. data/lib/generated/azure_mgmt_monitor/models/recurrence.rb +62 -0
  48. data/lib/generated/azure_mgmt_monitor/models/recurrence_frequency.rb +22 -0
  49. data/lib/generated/azure_mgmt_monitor/models/recurrent_schedule.rb +139 -0
  50. data/lib/generated/azure_mgmt_monitor/models/retention_policy.rb +60 -0
  51. data/lib/generated/azure_mgmt_monitor/models/rule_action.rb +48 -0
  52. data/lib/generated/azure_mgmt_monitor/models/rule_condition.rb +63 -0
  53. data/lib/generated/azure_mgmt_monitor/models/rule_data_source.rb +58 -0
  54. data/lib/generated/azure_mgmt_monitor/models/rule_email_action.rb +80 -0
  55. data/lib/generated/azure_mgmt_monitor/models/rule_management_event_claims_data_source.rb +45 -0
  56. data/lib/generated/azure_mgmt_monitor/models/rule_management_event_data_source.rb +150 -0
  57. data/lib/generated/azure_mgmt_monitor/models/rule_metric_data_source.rb +68 -0
  58. data/lib/generated/azure_mgmt_monitor/models/rule_webhook_action.rb +80 -0
  59. data/lib/generated/azure_mgmt_monitor/models/scale_action.rb +86 -0
  60. data/lib/generated/azure_mgmt_monitor/models/scale_capacity.rb +69 -0
  61. data/lib/generated/azure_mgmt_monitor/models/scale_direction.rb +17 -0
  62. data/lib/generated/azure_mgmt_monitor/models/scale_rule.rb +57 -0
  63. data/lib/generated/azure_mgmt_monitor/models/scale_type.rb +17 -0
  64. data/lib/generated/azure_mgmt_monitor/models/service_diagnostic_settings_resource.rb +163 -0
  65. data/lib/generated/azure_mgmt_monitor/models/service_diagnostic_settings_resource_patch.rb +135 -0
  66. data/lib/generated/azure_mgmt_monitor/models/sms_receiver.rb +79 -0
  67. data/lib/generated/azure_mgmt_monitor/models/threshold_rule_condition.rb +108 -0
  68. data/lib/generated/azure_mgmt_monitor/models/time_aggregation_operator.rb +19 -0
  69. data/lib/generated/azure_mgmt_monitor/models/time_aggregation_type.rb +19 -0
  70. data/lib/generated/azure_mgmt_monitor/models/time_window.rb +104 -0
  71. data/lib/generated/azure_mgmt_monitor/models/webhook_notification.rb +63 -0
  72. data/lib/generated/azure_mgmt_monitor/models/webhook_receiver.rb +56 -0
  73. data/lib/generated/azure_mgmt_monitor/module_definition.rb +8 -0
  74. data/lib/generated/azure_mgmt_monitor/monitor_management_client.rb +150 -0
  75. data/lib/generated/azure_mgmt_monitor/service_diagnostic_settings_operations.rb +330 -0
  76. data/lib/generated/azure_mgmt_monitor/version.rb +8 -0
  77. metadata +188 -0
@@ -0,0 +1,211 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 1.2.2.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::ARM::Monitor
7
+ #
8
+ # Monitor Management Client
9
+ #
10
+ class AlertRuleIncidents
11
+ include MsRestAzure
12
+
13
+ #
14
+ # Creates and initializes a new instance of the AlertRuleIncidents class.
15
+ # @param client service class for accessing basic functionality.
16
+ #
17
+ def initialize(client)
18
+ @client = client
19
+ end
20
+
21
+ # @return [MonitorManagementClient] reference to the MonitorManagementClient
22
+ attr_reader :client
23
+
24
+ #
25
+ # Gets an incident associated to an alert rule
26
+ #
27
+ # @param resource_group_name [String] The name of the resource group.
28
+ # @param rule_name [String] The name of the rule.
29
+ # @param incident_name [String] The name of the incident to retrieve.
30
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
31
+ # will be added to the HTTP request.
32
+ #
33
+ # @return [Incident] operation results.
34
+ #
35
+ def get(resource_group_name, rule_name, incident_name, custom_headers = nil)
36
+ response = get_async(resource_group_name, rule_name, incident_name, custom_headers).value!
37
+ response.body unless response.nil?
38
+ end
39
+
40
+ #
41
+ # Gets an incident associated to an alert rule
42
+ #
43
+ # @param resource_group_name [String] The name of the resource group.
44
+ # @param rule_name [String] The name of the rule.
45
+ # @param incident_name [String] The name of the incident to retrieve.
46
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
47
+ # will be added to the HTTP request.
48
+ #
49
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
50
+ #
51
+ def get_with_http_info(resource_group_name, rule_name, incident_name, custom_headers = nil)
52
+ get_async(resource_group_name, rule_name, incident_name, custom_headers).value!
53
+ end
54
+
55
+ #
56
+ # Gets an incident associated to an alert rule
57
+ #
58
+ # @param resource_group_name [String] The name of the resource group.
59
+ # @param rule_name [String] The name of the rule.
60
+ # @param incident_name [String] The name of the incident to retrieve.
61
+ # @param [Hash{String => String}] A hash of custom headers that will be added
62
+ # to the HTTP request.
63
+ #
64
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
65
+ #
66
+ def get_async(resource_group_name, rule_name, incident_name, custom_headers = nil)
67
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
68
+ fail ArgumentError, 'rule_name is nil' if rule_name.nil?
69
+ fail ArgumentError, 'incident_name is nil' if incident_name.nil?
70
+ api_version = '2016-03-01'
71
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
72
+
73
+
74
+ request_headers = {}
75
+
76
+ # Set Headers
77
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
78
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
79
+ path_template = 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents/{incidentName}'
80
+
81
+ request_url = @base_url || @client.base_url
82
+
83
+ options = {
84
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
85
+ path_params: {'resourceGroupName' => resource_group_name,'ruleName' => rule_name,'incidentName' => incident_name,'subscriptionId' => @client.subscription_id},
86
+ query_params: {'api-version' => api_version},
87
+ headers: request_headers.merge(custom_headers || {}),
88
+ base_url: request_url
89
+ }
90
+ promise = @client.make_request_async(:get, path_template, options)
91
+
92
+ promise = promise.then do |result|
93
+ http_response = result.response
94
+ status_code = http_response.status
95
+ response_content = http_response.body
96
+ unless status_code == 200
97
+ error_model = JSON.load(response_content)
98
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
99
+ end
100
+
101
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
102
+ # Deserialize Response
103
+ if status_code == 200
104
+ begin
105
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
106
+ result_mapper = Azure::ARM::Monitor::Models::Incident.mapper()
107
+ result.body = @client.deserialize(result_mapper, parsed_response)
108
+ rescue Exception => e
109
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
110
+ end
111
+ end
112
+
113
+ result
114
+ end
115
+
116
+ promise.execute
117
+ end
118
+
119
+ #
120
+ # Gets a list of incidents associated to an alert rule
121
+ #
122
+ # @param resource_group_name [String] The name of the resource group.
123
+ # @param rule_name [String] The name of the rule.
124
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
125
+ # will be added to the HTTP request.
126
+ #
127
+ # @return [IncidentListResult] operation results.
128
+ #
129
+ def list_by_alert_rule(resource_group_name, rule_name, custom_headers = nil)
130
+ response = list_by_alert_rule_async(resource_group_name, rule_name, custom_headers).value!
131
+ response.body unless response.nil?
132
+ end
133
+
134
+ #
135
+ # Gets a list of incidents associated to an alert rule
136
+ #
137
+ # @param resource_group_name [String] The name of the resource group.
138
+ # @param rule_name [String] The name of the rule.
139
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
140
+ # will be added to the HTTP request.
141
+ #
142
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
143
+ #
144
+ def list_by_alert_rule_with_http_info(resource_group_name, rule_name, custom_headers = nil)
145
+ list_by_alert_rule_async(resource_group_name, rule_name, custom_headers).value!
146
+ end
147
+
148
+ #
149
+ # Gets a list of incidents associated to an alert rule
150
+ #
151
+ # @param resource_group_name [String] The name of the resource group.
152
+ # @param rule_name [String] The name of the rule.
153
+ # @param [Hash{String => String}] A hash of custom headers that will be added
154
+ # to the HTTP request.
155
+ #
156
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
157
+ #
158
+ def list_by_alert_rule_async(resource_group_name, rule_name, custom_headers = nil)
159
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
160
+ fail ArgumentError, 'rule_name is nil' if rule_name.nil?
161
+ api_version = '2016-03-01'
162
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
163
+
164
+
165
+ request_headers = {}
166
+
167
+ # Set Headers
168
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
169
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
170
+ path_template = 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents'
171
+
172
+ request_url = @base_url || @client.base_url
173
+
174
+ options = {
175
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
176
+ path_params: {'resourceGroupName' => resource_group_name,'ruleName' => rule_name,'subscriptionId' => @client.subscription_id},
177
+ query_params: {'api-version' => api_version},
178
+ headers: request_headers.merge(custom_headers || {}),
179
+ base_url: request_url
180
+ }
181
+ promise = @client.make_request_async(:get, path_template, options)
182
+
183
+ promise = promise.then do |result|
184
+ http_response = result.response
185
+ status_code = http_response.status
186
+ response_content = http_response.body
187
+ unless status_code == 200
188
+ error_model = JSON.load(response_content)
189
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
190
+ end
191
+
192
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
193
+ # Deserialize Response
194
+ if status_code == 200
195
+ begin
196
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
197
+ result_mapper = Azure::ARM::Monitor::Models::IncidentListResult.mapper()
198
+ result.body = @client.deserialize(result_mapper, parsed_response)
199
+ rescue Exception => e
200
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
201
+ end
202
+ end
203
+
204
+ result
205
+ end
206
+
207
+ promise.execute
208
+ end
209
+
210
+ end
211
+ end
@@ -0,0 +1,510 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 1.2.2.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::ARM::Monitor
7
+ #
8
+ # Monitor Management Client
9
+ #
10
+ class AlertRules
11
+ include MsRestAzure
12
+
13
+ #
14
+ # Creates and initializes a new instance of the AlertRules class.
15
+ # @param client service class for accessing basic functionality.
16
+ #
17
+ def initialize(client)
18
+ @client = client
19
+ end
20
+
21
+ # @return [MonitorManagementClient] reference to the MonitorManagementClient
22
+ attr_reader :client
23
+
24
+ #
25
+ # Creates or updates an alert rule.
26
+ #
27
+ # @param resource_group_name [String] The name of the resource group.
28
+ # @param rule_name [String] The name of the rule.
29
+ # @param parameters [AlertRuleResource] The parameters of the rule to create or
30
+ # update.
31
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
32
+ # will be added to the HTTP request.
33
+ #
34
+ # @return [AlertRuleResource] operation results.
35
+ #
36
+ def create_or_update(resource_group_name, rule_name, parameters, custom_headers = nil)
37
+ response = create_or_update_async(resource_group_name, rule_name, parameters, custom_headers).value!
38
+ response.body unless response.nil?
39
+ end
40
+
41
+ #
42
+ # Creates or updates an alert rule.
43
+ #
44
+ # @param resource_group_name [String] The name of the resource group.
45
+ # @param rule_name [String] The name of the rule.
46
+ # @param parameters [AlertRuleResource] The parameters of the rule to create or
47
+ # update.
48
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
49
+ # will be added to the HTTP request.
50
+ #
51
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
52
+ #
53
+ def create_or_update_with_http_info(resource_group_name, rule_name, parameters, custom_headers = nil)
54
+ create_or_update_async(resource_group_name, rule_name, parameters, custom_headers).value!
55
+ end
56
+
57
+ #
58
+ # Creates or updates an alert rule.
59
+ #
60
+ # @param resource_group_name [String] The name of the resource group.
61
+ # @param rule_name [String] The name of the rule.
62
+ # @param parameters [AlertRuleResource] The parameters of the rule to create or
63
+ # update.
64
+ # @param [Hash{String => String}] A hash of custom headers that will be added
65
+ # to the HTTP request.
66
+ #
67
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
68
+ #
69
+ def create_or_update_async(resource_group_name, rule_name, parameters, custom_headers = nil)
70
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
71
+ fail ArgumentError, 'rule_name is nil' if rule_name.nil?
72
+ api_version = '2016-03-01'
73
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
74
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
75
+
76
+
77
+ request_headers = {}
78
+
79
+ # Set Headers
80
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
81
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
82
+
83
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
84
+
85
+ # Serialize Request
86
+ request_mapper = Azure::ARM::Monitor::Models::AlertRuleResource.mapper()
87
+ request_content = @client.serialize(request_mapper, parameters)
88
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
89
+
90
+ path_template = 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}'
91
+
92
+ request_url = @base_url || @client.base_url
93
+
94
+ options = {
95
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
96
+ path_params: {'resourceGroupName' => resource_group_name,'ruleName' => rule_name,'subscriptionId' => @client.subscription_id},
97
+ query_params: {'api-version' => api_version},
98
+ body: request_content,
99
+ headers: request_headers.merge(custom_headers || {}),
100
+ base_url: request_url
101
+ }
102
+ promise = @client.make_request_async(:put, path_template, options)
103
+
104
+ promise = promise.then do |result|
105
+ http_response = result.response
106
+ status_code = http_response.status
107
+ response_content = http_response.body
108
+ unless status_code == 200 || status_code == 201
109
+ error_model = JSON.load(response_content)
110
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
111
+ end
112
+
113
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
114
+ # Deserialize Response
115
+ if status_code == 200
116
+ begin
117
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
118
+ result_mapper = Azure::ARM::Monitor::Models::AlertRuleResource.mapper()
119
+ result.body = @client.deserialize(result_mapper, parsed_response)
120
+ rescue Exception => e
121
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
122
+ end
123
+ end
124
+ # Deserialize Response
125
+ if status_code == 201
126
+ begin
127
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
128
+ result_mapper = Azure::ARM::Monitor::Models::AlertRuleResource.mapper()
129
+ result.body = @client.deserialize(result_mapper, parsed_response)
130
+ rescue Exception => e
131
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
132
+ end
133
+ end
134
+
135
+ result
136
+ end
137
+
138
+ promise.execute
139
+ end
140
+
141
+ #
142
+ # Deletes an alert rule
143
+ #
144
+ # @param resource_group_name [String] The name of the resource group.
145
+ # @param rule_name [String] The name of the rule.
146
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
147
+ # will be added to the HTTP request.
148
+ #
149
+ #
150
+ def delete(resource_group_name, rule_name, custom_headers = nil)
151
+ response = delete_async(resource_group_name, rule_name, custom_headers).value!
152
+ nil
153
+ end
154
+
155
+ #
156
+ # Deletes an alert rule
157
+ #
158
+ # @param resource_group_name [String] The name of the resource group.
159
+ # @param rule_name [String] The name of the rule.
160
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
161
+ # will be added to the HTTP request.
162
+ #
163
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
164
+ #
165
+ def delete_with_http_info(resource_group_name, rule_name, custom_headers = nil)
166
+ delete_async(resource_group_name, rule_name, custom_headers).value!
167
+ end
168
+
169
+ #
170
+ # Deletes an alert rule
171
+ #
172
+ # @param resource_group_name [String] The name of the resource group.
173
+ # @param rule_name [String] The name of the rule.
174
+ # @param [Hash{String => String}] A hash of custom headers that will be added
175
+ # to the HTTP request.
176
+ #
177
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
178
+ #
179
+ def delete_async(resource_group_name, rule_name, custom_headers = nil)
180
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
181
+ fail ArgumentError, 'rule_name is nil' if rule_name.nil?
182
+ api_version = '2016-03-01'
183
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
184
+
185
+
186
+ request_headers = {}
187
+
188
+ # Set Headers
189
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
190
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
191
+ path_template = 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}'
192
+
193
+ request_url = @base_url || @client.base_url
194
+
195
+ options = {
196
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
197
+ path_params: {'resourceGroupName' => resource_group_name,'ruleName' => rule_name,'subscriptionId' => @client.subscription_id},
198
+ query_params: {'api-version' => api_version},
199
+ headers: request_headers.merge(custom_headers || {}),
200
+ base_url: request_url
201
+ }
202
+ promise = @client.make_request_async(:delete, path_template, options)
203
+
204
+ promise = promise.then do |result|
205
+ http_response = result.response
206
+ status_code = http_response.status
207
+ response_content = http_response.body
208
+ unless status_code == 204 || status_code == 200
209
+ error_model = JSON.load(response_content)
210
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
211
+ end
212
+
213
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
214
+
215
+ result
216
+ end
217
+
218
+ promise.execute
219
+ end
220
+
221
+ #
222
+ # Gets an alert rule
223
+ #
224
+ # @param resource_group_name [String] The name of the resource group.
225
+ # @param rule_name [String] The name of the rule.
226
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
227
+ # will be added to the HTTP request.
228
+ #
229
+ # @return [AlertRuleResource] operation results.
230
+ #
231
+ def get(resource_group_name, rule_name, custom_headers = nil)
232
+ response = get_async(resource_group_name, rule_name, custom_headers).value!
233
+ response.body unless response.nil?
234
+ end
235
+
236
+ #
237
+ # Gets an alert rule
238
+ #
239
+ # @param resource_group_name [String] The name of the resource group.
240
+ # @param rule_name [String] The name of the rule.
241
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
242
+ # will be added to the HTTP request.
243
+ #
244
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
245
+ #
246
+ def get_with_http_info(resource_group_name, rule_name, custom_headers = nil)
247
+ get_async(resource_group_name, rule_name, custom_headers).value!
248
+ end
249
+
250
+ #
251
+ # Gets an alert rule
252
+ #
253
+ # @param resource_group_name [String] The name of the resource group.
254
+ # @param rule_name [String] The name of the rule.
255
+ # @param [Hash{String => String}] A hash of custom headers that will be added
256
+ # to the HTTP request.
257
+ #
258
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
259
+ #
260
+ def get_async(resource_group_name, rule_name, custom_headers = nil)
261
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
262
+ fail ArgumentError, 'rule_name is nil' if rule_name.nil?
263
+ api_version = '2016-03-01'
264
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
265
+
266
+
267
+ request_headers = {}
268
+
269
+ # Set Headers
270
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
271
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
272
+ path_template = 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}'
273
+
274
+ request_url = @base_url || @client.base_url
275
+
276
+ options = {
277
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
278
+ path_params: {'resourceGroupName' => resource_group_name,'ruleName' => rule_name,'subscriptionId' => @client.subscription_id},
279
+ query_params: {'api-version' => api_version},
280
+ headers: request_headers.merge(custom_headers || {}),
281
+ base_url: request_url
282
+ }
283
+ promise = @client.make_request_async(:get, path_template, options)
284
+
285
+ promise = promise.then do |result|
286
+ http_response = result.response
287
+ status_code = http_response.status
288
+ response_content = http_response.body
289
+ unless status_code == 200
290
+ error_model = JSON.load(response_content)
291
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
292
+ end
293
+
294
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
295
+ # Deserialize Response
296
+ if status_code == 200
297
+ begin
298
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
299
+ result_mapper = Azure::ARM::Monitor::Models::AlertRuleResource.mapper()
300
+ result.body = @client.deserialize(result_mapper, parsed_response)
301
+ rescue Exception => e
302
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
303
+ end
304
+ end
305
+
306
+ result
307
+ end
308
+
309
+ promise.execute
310
+ end
311
+
312
+ #
313
+ # Updates an existing AlertRuleResource. To update other fields use the
314
+ # CreateOrUpdate method.
315
+ #
316
+ # @param resource_group_name [String] The name of the resource group.
317
+ # @param rule_name [String] The name of the rule.
318
+ # @param alert_rules_resource [AlertRuleResourcePatch] Parameters supplied to
319
+ # the operation.
320
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
321
+ # will be added to the HTTP request.
322
+ #
323
+ # @return [AlertRuleResource] operation results.
324
+ #
325
+ def update(resource_group_name, rule_name, alert_rules_resource, custom_headers = nil)
326
+ response = update_async(resource_group_name, rule_name, alert_rules_resource, custom_headers).value!
327
+ response.body unless response.nil?
328
+ end
329
+
330
+ #
331
+ # Updates an existing AlertRuleResource. To update other fields use the
332
+ # CreateOrUpdate method.
333
+ #
334
+ # @param resource_group_name [String] The name of the resource group.
335
+ # @param rule_name [String] The name of the rule.
336
+ # @param alert_rules_resource [AlertRuleResourcePatch] Parameters supplied to
337
+ # the operation.
338
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
339
+ # will be added to the HTTP request.
340
+ #
341
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
342
+ #
343
+ def update_with_http_info(resource_group_name, rule_name, alert_rules_resource, custom_headers = nil)
344
+ update_async(resource_group_name, rule_name, alert_rules_resource, custom_headers).value!
345
+ end
346
+
347
+ #
348
+ # Updates an existing AlertRuleResource. To update other fields use the
349
+ # CreateOrUpdate method.
350
+ #
351
+ # @param resource_group_name [String] The name of the resource group.
352
+ # @param rule_name [String] The name of the rule.
353
+ # @param alert_rules_resource [AlertRuleResourcePatch] Parameters supplied to
354
+ # the operation.
355
+ # @param [Hash{String => String}] A hash of custom headers that will be added
356
+ # to the HTTP request.
357
+ #
358
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
359
+ #
360
+ def update_async(resource_group_name, rule_name, alert_rules_resource, custom_headers = nil)
361
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
362
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
363
+ fail ArgumentError, 'rule_name is nil' if rule_name.nil?
364
+ api_version = '2016-03-01'
365
+ fail ArgumentError, 'alert_rules_resource is nil' if alert_rules_resource.nil?
366
+
367
+
368
+ request_headers = {}
369
+
370
+ # Set Headers
371
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
372
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
373
+
374
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
375
+
376
+ # Serialize Request
377
+ request_mapper = Azure::ARM::Monitor::Models::AlertRuleResourcePatch.mapper()
378
+ request_content = @client.serialize(request_mapper, alert_rules_resource)
379
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
380
+
381
+ path_template = 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}'
382
+
383
+ request_url = @base_url || @client.base_url
384
+
385
+ options = {
386
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
387
+ path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'ruleName' => rule_name},
388
+ query_params: {'api-version' => api_version},
389
+ body: request_content,
390
+ headers: request_headers.merge(custom_headers || {}),
391
+ base_url: request_url
392
+ }
393
+ promise = @client.make_request_async(:patch, path_template, options)
394
+
395
+ promise = promise.then do |result|
396
+ http_response = result.response
397
+ status_code = http_response.status
398
+ response_content = http_response.body
399
+ unless status_code == 200
400
+ error_model = JSON.load(response_content)
401
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
402
+ end
403
+
404
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
405
+ # Deserialize Response
406
+ if status_code == 200
407
+ begin
408
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
409
+ result_mapper = Azure::ARM::Monitor::Models::AlertRuleResource.mapper()
410
+ result.body = @client.deserialize(result_mapper, parsed_response)
411
+ rescue Exception => e
412
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
413
+ end
414
+ end
415
+
416
+ result
417
+ end
418
+
419
+ promise.execute
420
+ end
421
+
422
+ #
423
+ # List the alert rules within a resource group.
424
+ #
425
+ # @param resource_group_name [String] The name of the resource group.
426
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
427
+ # will be added to the HTTP request.
428
+ #
429
+ # @return [AlertRuleResourceCollection] operation results.
430
+ #
431
+ def list_by_resource_group(resource_group_name, custom_headers = nil)
432
+ response = list_by_resource_group_async(resource_group_name, custom_headers).value!
433
+ response.body unless response.nil?
434
+ end
435
+
436
+ #
437
+ # List the alert rules within a resource group.
438
+ #
439
+ # @param resource_group_name [String] The name of the resource group.
440
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
441
+ # will be added to the HTTP request.
442
+ #
443
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
444
+ #
445
+ def list_by_resource_group_with_http_info(resource_group_name, custom_headers = nil)
446
+ list_by_resource_group_async(resource_group_name, custom_headers).value!
447
+ end
448
+
449
+ #
450
+ # List the alert rules within a resource group.
451
+ #
452
+ # @param resource_group_name [String] The name of the resource group.
453
+ # @param [Hash{String => String}] A hash of custom headers that will be added
454
+ # to the HTTP request.
455
+ #
456
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
457
+ #
458
+ def list_by_resource_group_async(resource_group_name, custom_headers = nil)
459
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
460
+ api_version = '2016-03-01'
461
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
462
+
463
+
464
+ request_headers = {}
465
+
466
+ # Set Headers
467
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
468
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
469
+ path_template = 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules'
470
+
471
+ request_url = @base_url || @client.base_url
472
+
473
+ options = {
474
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
475
+ path_params: {'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id},
476
+ query_params: {'api-version' => api_version},
477
+ headers: request_headers.merge(custom_headers || {}),
478
+ base_url: request_url
479
+ }
480
+ promise = @client.make_request_async(:get, path_template, options)
481
+
482
+ promise = promise.then do |result|
483
+ http_response = result.response
484
+ status_code = http_response.status
485
+ response_content = http_response.body
486
+ unless status_code == 200
487
+ error_model = JSON.load(response_content)
488
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
489
+ end
490
+
491
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
492
+ # Deserialize Response
493
+ if status_code == 200
494
+ begin
495
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
496
+ result_mapper = Azure::ARM::Monitor::Models::AlertRuleResourceCollection.mapper()
497
+ result.body = @client.deserialize(result_mapper, parsed_response)
498
+ rescue Exception => e
499
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
500
+ end
501
+ end
502
+
503
+ result
504
+ end
505
+
506
+ promise.execute
507
+ end
508
+
509
+ end
510
+ end