azure_mgmt_security 0.18.1 → 0.18.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/lib/2015-06-01-preview/generated/azure_mgmt_security/security_center.rb +1 -1
  3. data/lib/2017-08-01-preview/generated/azure_mgmt_security/security_center.rb +1 -1
  4. data/lib/2017-08-01/generated/azure_mgmt_security/security_center.rb +1 -1
  5. data/lib/2018-06-01/generated/azure_mgmt_security/security_center.rb +1 -1
  6. data/lib/2019-01-01-preview/generated/azure_mgmt_security/security_center.rb +1 -1
  7. data/lib/2019-01-01/generated/azure_mgmt_security/security_center.rb +1 -1
  8. data/lib/2019-08-01/generated/azure_mgmt_security/security_center.rb +1 -1
  9. data/lib/2020-01-01-preview/generated/azure_mgmt_security.rb +48 -0
  10. data/lib/2020-01-01-preview/generated/azure_mgmt_security/models/asc_location.rb +73 -0
  11. data/lib/2020-01-01-preview/generated/azure_mgmt_security/models/azure_resource_link.rb +47 -0
  12. data/lib/2020-01-01-preview/generated/azure_mgmt_security/models/control_type.rb +16 -0
  13. data/lib/2020-01-01-preview/generated/azure_mgmt_security/models/etag.rb +48 -0
  14. data/lib/2020-01-01-preview/generated/azure_mgmt_security/models/expand_controls_enum.rb +15 -0
  15. data/lib/2020-01-01-preview/generated/azure_mgmt_security/models/kind.rb +46 -0
  16. data/lib/2020-01-01-preview/generated/azure_mgmt_security/models/location.rb +47 -0
  17. data/lib/2020-01-01-preview/generated/azure_mgmt_security/models/resource.rb +80 -0
  18. data/lib/2020-01-01-preview/generated/azure_mgmt_security/models/secure_score_control_definition_item.rb +141 -0
  19. data/lib/2020-01-01-preview/generated/azure_mgmt_security/models/secure_score_control_definition_list.rb +101 -0
  20. data/lib/2020-01-01-preview/generated/azure_mgmt_security/models/secure_score_control_definition_source.rb +47 -0
  21. data/lib/2020-01-01-preview/generated/azure_mgmt_security/models/secure_score_control_details.rb +153 -0
  22. data/lib/2020-01-01-preview/generated/azure_mgmt_security/models/secure_score_control_list.rb +101 -0
  23. data/lib/2020-01-01-preview/generated/azure_mgmt_security/models/secure_score_control_score.rb +69 -0
  24. data/lib/2020-01-01-preview/generated/azure_mgmt_security/models/secure_score_item.rb +104 -0
  25. data/lib/2020-01-01-preview/generated/azure_mgmt_security/models/secure_scores_list.rb +101 -0
  26. data/lib/2020-01-01-preview/generated/azure_mgmt_security/models/tags.rb +55 -0
  27. data/lib/2020-01-01-preview/generated/azure_mgmt_security/models/tracked_resource.rb +126 -0
  28. data/lib/2020-01-01-preview/generated/azure_mgmt_security/module_definition.rb +9 -0
  29. data/lib/2020-01-01-preview/generated/azure_mgmt_security/secure_score_control_definitions.rb +423 -0
  30. data/lib/2020-01-01-preview/generated/azure_mgmt_security/secure_score_controls.rb +444 -0
  31. data/lib/2020-01-01-preview/generated/azure_mgmt_security/secure_scores.rb +326 -0
  32. data/lib/2020-01-01-preview/generated/azure_mgmt_security/security_center.rb +139 -0
  33. data/lib/2020-01-01/generated/azure_mgmt_security.rb +121 -0
  34. data/lib/2020-01-01/generated/azure_mgmt_security/adaptive_application_controls.rb +394 -0
  35. data/lib/2020-01-01/generated/azure_mgmt_security/adaptive_network_hardenings.rb +539 -0
  36. data/lib/2020-01-01/generated/azure_mgmt_security/allowed_connections.rb +535 -0
  37. data/lib/2020-01-01/generated/azure_mgmt_security/assessments.rb +555 -0
  38. data/lib/2020-01-01/generated/azure_mgmt_security/assessments_metadata.rb +799 -0
  39. data/lib/2020-01-01/generated/azure_mgmt_security/discovered_security_solutions.rb +532 -0
  40. data/lib/2020-01-01/generated/azure_mgmt_security/external_security_solutions.rb +525 -0
  41. data/lib/2020-01-01/generated/azure_mgmt_security/jit_network_access_policies.rb +1295 -0
  42. data/lib/2020-01-01/generated/azure_mgmt_security/models/aad_connectivity_state.rb +17 -0
  43. data/lib/2020-01-01/generated/azure_mgmt_security/models/aad_connectivity_state1.rb +48 -0
  44. data/lib/2020-01-01/generated/azure_mgmt_security/models/aad_external_security_solution.rb +99 -0
  45. data/lib/2020-01-01/generated/azure_mgmt_security/models/aad_solution_properties.rb +83 -0
  46. data/lib/2020-01-01/generated/azure_mgmt_security/models/adaptive_network_hardening.rb +116 -0
  47. data/lib/2020-01-01/generated/azure_mgmt_security/models/adaptive_network_hardening_enforce_request.rb +77 -0
  48. data/lib/2020-01-01/generated/azure_mgmt_security/models/adaptive_network_hardenings_list.rb +99 -0
  49. data/lib/2020-01-01/generated/azure_mgmt_security/models/allowed_connections_list.rb +100 -0
  50. data/lib/2020-01-01/generated/azure_mgmt_security/models/allowed_connections_resource.rb +118 -0
  51. data/lib/2020-01-01/generated/azure_mgmt_security/models/app_whitelisting_group.rb +207 -0
  52. data/lib/2020-01-01/generated/azure_mgmt_security/models/app_whitelisting_groups.rb +56 -0
  53. data/lib/2020-01-01/generated/azure_mgmt_security/models/app_whitelisting_issue_summary.rb +61 -0
  54. data/lib/2020-01-01/generated/azure_mgmt_security/models/asc_location.rb +73 -0
  55. data/lib/2020-01-01/generated/azure_mgmt_security/models/assessment_links.rb +47 -0
  56. data/lib/2020-01-01/generated/azure_mgmt_security/models/assessment_status.rb +71 -0
  57. data/lib/2020-01-01/generated/azure_mgmt_security/models/assessment_status_code.rb +17 -0
  58. data/lib/2020-01-01/generated/azure_mgmt_security/models/assessment_type.rb +18 -0
  59. data/lib/2020-01-01/generated/azure_mgmt_security/models/ata_external_security_solution.rb +98 -0
  60. data/lib/2020-01-01/generated/azure_mgmt_security/models/ata_solution_properties.rb +87 -0
  61. data/lib/2020-01-01/generated/azure_mgmt_security/models/azure_resource_details.rb +62 -0
  62. data/lib/2020-01-01/generated/azure_mgmt_security/models/category.rb +19 -0
  63. data/lib/2020-01-01/generated/azure_mgmt_security/models/cef_external_security_solution.rb +98 -0
  64. data/lib/2020-01-01/generated/azure_mgmt_security/models/cef_solution_properties.rb +109 -0
  65. data/lib/2020-01-01/generated/azure_mgmt_security/models/connectable_resource.rb +91 -0
  66. data/lib/2020-01-01/generated/azure_mgmt_security/models/connected_resource.rb +71 -0
  67. data/lib/2020-01-01/generated/azure_mgmt_security/models/connected_workspace.rb +47 -0
  68. data/lib/2020-01-01/generated/azure_mgmt_security/models/connection_type.rb +16 -0
  69. data/lib/2020-01-01/generated/azure_mgmt_security/models/direction.rb +16 -0
  70. data/lib/2020-01-01/generated/azure_mgmt_security/models/discovered_security_solution.rb +129 -0
  71. data/lib/2020-01-01/generated/azure_mgmt_security/models/discovered_security_solution_list.rb +99 -0
  72. data/lib/2020-01-01/generated/azure_mgmt_security/models/effective_network_security_groups.rb +66 -0
  73. data/lib/2020-01-01/generated/azure_mgmt_security/models/etag.rb +48 -0
  74. data/lib/2020-01-01/generated/azure_mgmt_security/models/expand_enum.rb +16 -0
  75. data/lib/2020-01-01/generated/azure_mgmt_security/models/external_security_solution.rb +98 -0
  76. data/lib/2020-01-01/generated/azure_mgmt_security/models/external_security_solution_kind.rb +17 -0
  77. data/lib/2020-01-01/generated/azure_mgmt_security/models/external_security_solution_kind1.rb +47 -0
  78. data/lib/2020-01-01/generated/azure_mgmt_security/models/external_security_solution_list.rb +101 -0
  79. data/lib/2020-01-01/generated/azure_mgmt_security/models/external_security_solution_properties.rb +88 -0
  80. data/lib/2020-01-01/generated/azure_mgmt_security/models/implementation_effort.rb +17 -0
  81. data/lib/2020-01-01/generated/azure_mgmt_security/models/jit_network_access_policies_list.rb +99 -0
  82. data/lib/2020-01-01/generated/azure_mgmt_security/models/jit_network_access_policy.rb +149 -0
  83. data/lib/2020-01-01/generated/azure_mgmt_security/models/jit_network_access_policy_initiate_port.rb +70 -0
  84. data/lib/2020-01-01/generated/azure_mgmt_security/models/jit_network_access_policy_initiate_request.rb +68 -0
  85. data/lib/2020-01-01/generated/azure_mgmt_security/models/jit_network_access_policy_initiate_virtual_machine.rb +70 -0
  86. data/lib/2020-01-01/generated/azure_mgmt_security/models/jit_network_access_policy_virtual_machine.rb +81 -0
  87. data/lib/2020-01-01/generated/azure_mgmt_security/models/jit_network_access_port_rule.rb +103 -0
  88. data/lib/2020-01-01/generated/azure_mgmt_security/models/jit_network_access_request.rb +89 -0
  89. data/lib/2020-01-01/generated/azure_mgmt_security/models/jit_network_access_request_port.rb +128 -0
  90. data/lib/2020-01-01/generated/azure_mgmt_security/models/jit_network_access_request_virtual_machine.rb +69 -0
  91. data/lib/2020-01-01/generated/azure_mgmt_security/models/kind.rb +46 -0
  92. data/lib/2020-01-01/generated/azure_mgmt_security/models/location.rb +47 -0
  93. data/lib/2020-01-01/generated/azure_mgmt_security/models/on_premise_resource_details.rb +95 -0
  94. data/lib/2020-01-01/generated/azure_mgmt_security/models/path_recommendation.rb +156 -0
  95. data/lib/2020-01-01/generated/azure_mgmt_security/models/protection_mode.rb +80 -0
  96. data/lib/2020-01-01/generated/azure_mgmt_security/models/protocol.rb +17 -0
  97. data/lib/2020-01-01/generated/azure_mgmt_security/models/publisher_info.rb +84 -0
  98. data/lib/2020-01-01/generated/azure_mgmt_security/models/resource.rb +80 -0
  99. data/lib/2020-01-01/generated/azure_mgmt_security/models/resource_details.rb +47 -0
  100. data/lib/2020-01-01/generated/azure_mgmt_security/models/rule.rb +111 -0
  101. data/lib/2020-01-01/generated/azure_mgmt_security/models/security_assessment.rb +156 -0
  102. data/lib/2020-01-01/generated/azure_mgmt_security/models/security_assessment_list.rb +101 -0
  103. data/lib/2020-01-01/generated/azure_mgmt_security/models/security_assessment_metadata.rb +221 -0
  104. data/lib/2020-01-01/generated/azure_mgmt_security/models/security_assessment_metadata_list.rb +100 -0
  105. data/lib/2020-01-01/generated/azure_mgmt_security/models/security_assessment_metadata_partner_data.rb +70 -0
  106. data/lib/2020-01-01/generated/azure_mgmt_security/models/security_assessment_metadata_properties.rb +194 -0
  107. data/lib/2020-01-01/generated/azure_mgmt_security/models/security_assessment_partner_data.rb +57 -0
  108. data/lib/2020-01-01/generated/azure_mgmt_security/models/security_family.rb +18 -0
  109. data/lib/2020-01-01/generated/azure_mgmt_security/models/server_vulnerability_assessment.rb +76 -0
  110. data/lib/2020-01-01/generated/azure_mgmt_security/models/server_vulnerability_assessments_list.rb +55 -0
  111. data/lib/2020-01-01/generated/azure_mgmt_security/models/severity.rb +17 -0
  112. data/lib/2020-01-01/generated/azure_mgmt_security/models/status.rb +16 -0
  113. data/lib/2020-01-01/generated/azure_mgmt_security/models/status_reason.rb +17 -0
  114. data/lib/2020-01-01/generated/azure_mgmt_security/models/tags.rb +55 -0
  115. data/lib/2020-01-01/generated/azure_mgmt_security/models/threats.rb +22 -0
  116. data/lib/2020-01-01/generated/azure_mgmt_security/models/topology_list.rb +100 -0
  117. data/lib/2020-01-01/generated/azure_mgmt_security/models/topology_resource.rb +118 -0
  118. data/lib/2020-01-01/generated/azure_mgmt_security/models/topology_single_resource.rb +154 -0
  119. data/lib/2020-01-01/generated/azure_mgmt_security/models/topology_single_resource_child.rb +49 -0
  120. data/lib/2020-01-01/generated/azure_mgmt_security/models/topology_single_resource_parent.rb +49 -0
  121. data/lib/2020-01-01/generated/azure_mgmt_security/models/tracked_resource.rb +126 -0
  122. data/lib/2020-01-01/generated/azure_mgmt_security/models/transport_protocol.rb +16 -0
  123. data/lib/2020-01-01/generated/azure_mgmt_security/models/user_impact.rb +17 -0
  124. data/lib/2020-01-01/generated/azure_mgmt_security/models/user_recommendation.rb +58 -0
  125. data/lib/2020-01-01/generated/azure_mgmt_security/models/vm_recommendation.rb +81 -0
  126. data/lib/2020-01-01/generated/azure_mgmt_security/module_definition.rb +9 -0
  127. data/lib/2020-01-01/generated/azure_mgmt_security/security_center.rb +172 -0
  128. data/lib/2020-01-01/generated/azure_mgmt_security/server_vulnerability_assessment_operations.rb +462 -0
  129. data/lib/2020-01-01/generated/azure_mgmt_security/topology.rb +530 -0
  130. data/lib/azure_mgmt_security.rb +2 -0
  131. data/lib/profiles/latest/modules/security_profile_module.rb +366 -258
  132. data/lib/version.rb +1 -1
  133. metadata +123 -2
@@ -0,0 +1,555 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator.
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::Security::Mgmt::V2020_01_01
7
+ #
8
+ # API spec for Microsoft.Security (Azure Security Center) resource provider
9
+ #
10
+ class Assessments
11
+ include MsRestAzure
12
+
13
+ #
14
+ # Creates and initializes a new instance of the Assessments class.
15
+ # @param client service class for accessing basic functionality.
16
+ #
17
+ def initialize(client)
18
+ @client = client
19
+ end
20
+
21
+ # @return [SecurityCenter] reference to the SecurityCenter
22
+ attr_reader :client
23
+
24
+ #
25
+ # Get security assessments on all your scanned resources inside a scope
26
+ #
27
+ # @param scope [String] Scope of the query, can be subscription
28
+ # (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group
29
+ # (/providers/Microsoft.Management/managementGroups/mgName).
30
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
31
+ # will be added to the HTTP request.
32
+ #
33
+ # @return [Array<SecurityAssessment>] operation results.
34
+ #
35
+ def list(scope, custom_headers:nil)
36
+ first_page = list_as_lazy(scope, custom_headers:custom_headers)
37
+ first_page.get_all_items
38
+ end
39
+
40
+ #
41
+ # Get security assessments on all your scanned resources inside a scope
42
+ #
43
+ # @param scope [String] Scope of the query, can be subscription
44
+ # (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group
45
+ # (/providers/Microsoft.Management/managementGroups/mgName).
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 list_with_http_info(scope, custom_headers:nil)
52
+ list_async(scope, custom_headers:custom_headers).value!
53
+ end
54
+
55
+ #
56
+ # Get security assessments on all your scanned resources inside a scope
57
+ #
58
+ # @param scope [String] Scope of the query, can be subscription
59
+ # (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group
60
+ # (/providers/Microsoft.Management/managementGroups/mgName).
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 list_async(scope, custom_headers:nil)
67
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
68
+ fail ArgumentError, 'scope is nil' if scope.nil?
69
+
70
+
71
+ request_headers = {}
72
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
73
+
74
+ # Set Headers
75
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
76
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
77
+ path_template = '{scope}/providers/Microsoft.Security/assessments'
78
+
79
+ request_url = @base_url || @client.base_url
80
+
81
+ options = {
82
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
83
+ skip_encoding_path_params: {'scope' => scope},
84
+ query_params: {'api-version' => @client.api_version},
85
+ headers: request_headers.merge(custom_headers || {}),
86
+ base_url: request_url
87
+ }
88
+ promise = @client.make_request_async(:get, path_template, options)
89
+
90
+ promise = promise.then do |result|
91
+ http_response = result.response
92
+ status_code = http_response.status
93
+ response_content = http_response.body
94
+ unless status_code == 200
95
+ error_model = JSON.load(response_content)
96
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
97
+ end
98
+
99
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
100
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
101
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-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::Security::Mgmt::V2020_01_01::Models::SecurityAssessmentList.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
+ # Get a security assessment on your scanned resource
121
+ #
122
+ # @param resource_id [String] The identifier of the resource.
123
+ # @param assessment_name [String] The Assessment Key - Unique key for the
124
+ # assessment type
125
+ # @param expand [ExpandEnum] OData expand. Optional. Possible values include:
126
+ # 'links', 'metadata'
127
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
128
+ # will be added to the HTTP request.
129
+ #
130
+ # @return [SecurityAssessment] operation results.
131
+ #
132
+ def get(resource_id, assessment_name, expand:nil, custom_headers:nil)
133
+ response = get_async(resource_id, assessment_name, expand:expand, custom_headers:custom_headers).value!
134
+ response.body unless response.nil?
135
+ end
136
+
137
+ #
138
+ # Get a security assessment on your scanned resource
139
+ #
140
+ # @param resource_id [String] The identifier of the resource.
141
+ # @param assessment_name [String] The Assessment Key - Unique key for the
142
+ # assessment type
143
+ # @param expand [ExpandEnum] OData expand. Optional. Possible values include:
144
+ # 'links', 'metadata'
145
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
146
+ # will be added to the HTTP request.
147
+ #
148
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
149
+ #
150
+ def get_with_http_info(resource_id, assessment_name, expand:nil, custom_headers:nil)
151
+ get_async(resource_id, assessment_name, expand:expand, custom_headers:custom_headers).value!
152
+ end
153
+
154
+ #
155
+ # Get a security assessment on your scanned resource
156
+ #
157
+ # @param resource_id [String] The identifier of the resource.
158
+ # @param assessment_name [String] The Assessment Key - Unique key for the
159
+ # assessment type
160
+ # @param expand [ExpandEnum] OData expand. Optional. Possible values include:
161
+ # 'links', 'metadata'
162
+ # @param [Hash{String => String}] A hash of custom headers that will be added
163
+ # to the HTTP request.
164
+ #
165
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
166
+ #
167
+ def get_async(resource_id, assessment_name, expand:nil, custom_headers:nil)
168
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
169
+ fail ArgumentError, 'resource_id is nil' if resource_id.nil?
170
+ fail ArgumentError, 'assessment_name is nil' if assessment_name.nil?
171
+
172
+
173
+ request_headers = {}
174
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
175
+
176
+ # Set Headers
177
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
178
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
179
+ path_template = '{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}'
180
+
181
+ request_url = @base_url || @client.base_url
182
+
183
+ options = {
184
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
185
+ path_params: {'assessmentName' => assessment_name},
186
+ skip_encoding_path_params: {'resourceId' => resource_id},
187
+ query_params: {'api-version' => @client.api_version,'$expand' => expand},
188
+ headers: request_headers.merge(custom_headers || {}),
189
+ base_url: request_url
190
+ }
191
+ promise = @client.make_request_async(:get, path_template, options)
192
+
193
+ promise = promise.then do |result|
194
+ http_response = result.response
195
+ status_code = http_response.status
196
+ response_content = http_response.body
197
+ unless status_code == 200
198
+ error_model = JSON.load(response_content)
199
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
200
+ end
201
+
202
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
203
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
204
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
205
+ # Deserialize Response
206
+ if status_code == 200
207
+ begin
208
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
209
+ result_mapper = Azure::Security::Mgmt::V2020_01_01::Models::SecurityAssessment.mapper()
210
+ result.body = @client.deserialize(result_mapper, parsed_response)
211
+ rescue Exception => e
212
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
213
+ end
214
+ end
215
+
216
+ result
217
+ end
218
+
219
+ promise.execute
220
+ end
221
+
222
+ #
223
+ # Create a security assessment on your resource. An assessment metadata that
224
+ # describes this assessment must be predefined with the same name before
225
+ # inserting the assessment result
226
+ #
227
+ # @param resource_id [String] The identifier of the resource.
228
+ # @param assessment_name [String] The Assessment Key - Unique key for the
229
+ # assessment type
230
+ # @param assessment [SecurityAssessment] Calculated assessment on a pre-defined
231
+ # assessment metadata
232
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
233
+ # will be added to the HTTP request.
234
+ #
235
+ # @return [SecurityAssessment] operation results.
236
+ #
237
+ def create_or_update(resource_id, assessment_name, assessment, custom_headers:nil)
238
+ response = create_or_update_async(resource_id, assessment_name, assessment, custom_headers:custom_headers).value!
239
+ response.body unless response.nil?
240
+ end
241
+
242
+ #
243
+ # Create a security assessment on your resource. An assessment metadata that
244
+ # describes this assessment must be predefined with the same name before
245
+ # inserting the assessment result
246
+ #
247
+ # @param resource_id [String] The identifier of the resource.
248
+ # @param assessment_name [String] The Assessment Key - Unique key for the
249
+ # assessment type
250
+ # @param assessment [SecurityAssessment] Calculated assessment on a pre-defined
251
+ # assessment metadata
252
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
253
+ # will be added to the HTTP request.
254
+ #
255
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
256
+ #
257
+ def create_or_update_with_http_info(resource_id, assessment_name, assessment, custom_headers:nil)
258
+ create_or_update_async(resource_id, assessment_name, assessment, custom_headers:custom_headers).value!
259
+ end
260
+
261
+ #
262
+ # Create a security assessment on your resource. An assessment metadata that
263
+ # describes this assessment must be predefined with the same name before
264
+ # inserting the assessment result
265
+ #
266
+ # @param resource_id [String] The identifier of the resource.
267
+ # @param assessment_name [String] The Assessment Key - Unique key for the
268
+ # assessment type
269
+ # @param assessment [SecurityAssessment] Calculated assessment on a pre-defined
270
+ # assessment metadata
271
+ # @param [Hash{String => String}] A hash of custom headers that will be added
272
+ # to the HTTP request.
273
+ #
274
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
275
+ #
276
+ def create_or_update_async(resource_id, assessment_name, assessment, custom_headers:nil)
277
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
278
+ fail ArgumentError, 'resource_id is nil' if resource_id.nil?
279
+ fail ArgumentError, 'assessment_name is nil' if assessment_name.nil?
280
+ fail ArgumentError, 'assessment is nil' if assessment.nil?
281
+
282
+
283
+ request_headers = {}
284
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
285
+
286
+ # Set Headers
287
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
288
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
289
+
290
+ # Serialize Request
291
+ request_mapper = Azure::Security::Mgmt::V2020_01_01::Models::SecurityAssessment.mapper()
292
+ request_content = @client.serialize(request_mapper, assessment)
293
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
294
+
295
+ path_template = '{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}'
296
+
297
+ request_url = @base_url || @client.base_url
298
+
299
+ options = {
300
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
301
+ path_params: {'assessmentName' => assessment_name},
302
+ skip_encoding_path_params: {'resourceId' => resource_id},
303
+ query_params: {'api-version' => @client.api_version},
304
+ body: request_content,
305
+ headers: request_headers.merge(custom_headers || {}),
306
+ base_url: request_url
307
+ }
308
+ promise = @client.make_request_async(:put, path_template, options)
309
+
310
+ promise = promise.then do |result|
311
+ http_response = result.response
312
+ status_code = http_response.status
313
+ response_content = http_response.body
314
+ unless status_code == 201 || status_code == 200
315
+ error_model = JSON.load(response_content)
316
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
317
+ end
318
+
319
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
320
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
321
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
322
+ # Deserialize Response
323
+ if status_code == 201
324
+ begin
325
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
326
+ result_mapper = Azure::Security::Mgmt::V2020_01_01::Models::SecurityAssessment.mapper()
327
+ result.body = @client.deserialize(result_mapper, parsed_response)
328
+ rescue Exception => e
329
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
330
+ end
331
+ end
332
+ # Deserialize Response
333
+ if status_code == 200
334
+ begin
335
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
336
+ result_mapper = Azure::Security::Mgmt::V2020_01_01::Models::SecurityAssessment.mapper()
337
+ result.body = @client.deserialize(result_mapper, parsed_response)
338
+ rescue Exception => e
339
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
340
+ end
341
+ end
342
+
343
+ result
344
+ end
345
+
346
+ promise.execute
347
+ end
348
+
349
+ #
350
+ # Delete a security assessment on your resource. An assessment metadata that
351
+ # describes this assessment must be predefined with the same name before
352
+ # inserting the assessment result
353
+ #
354
+ # @param resource_id [String] The identifier of the resource.
355
+ # @param assessment_name [String] The Assessment Key - Unique key for the
356
+ # assessment type
357
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
358
+ # will be added to the HTTP request.
359
+ #
360
+ #
361
+ def delete(resource_id, assessment_name, custom_headers:nil)
362
+ response = delete_async(resource_id, assessment_name, custom_headers:custom_headers).value!
363
+ nil
364
+ end
365
+
366
+ #
367
+ # Delete a security assessment on your resource. An assessment metadata that
368
+ # describes this assessment must be predefined with the same name before
369
+ # inserting the assessment result
370
+ #
371
+ # @param resource_id [String] The identifier of the resource.
372
+ # @param assessment_name [String] The Assessment Key - Unique key for the
373
+ # assessment type
374
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
375
+ # will be added to the HTTP request.
376
+ #
377
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
378
+ #
379
+ def delete_with_http_info(resource_id, assessment_name, custom_headers:nil)
380
+ delete_async(resource_id, assessment_name, custom_headers:custom_headers).value!
381
+ end
382
+
383
+ #
384
+ # Delete a security assessment on your resource. An assessment metadata that
385
+ # describes this assessment must be predefined with the same name before
386
+ # inserting the assessment result
387
+ #
388
+ # @param resource_id [String] The identifier of the resource.
389
+ # @param assessment_name [String] The Assessment Key - Unique key for the
390
+ # assessment type
391
+ # @param [Hash{String => String}] A hash of custom headers that will be added
392
+ # to the HTTP request.
393
+ #
394
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
395
+ #
396
+ def delete_async(resource_id, assessment_name, custom_headers:nil)
397
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
398
+ fail ArgumentError, 'resource_id is nil' if resource_id.nil?
399
+ fail ArgumentError, 'assessment_name is nil' if assessment_name.nil?
400
+
401
+
402
+ request_headers = {}
403
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
404
+
405
+ # Set Headers
406
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
407
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
408
+ path_template = '{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}'
409
+
410
+ request_url = @base_url || @client.base_url
411
+
412
+ options = {
413
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
414
+ path_params: {'assessmentName' => assessment_name},
415
+ skip_encoding_path_params: {'resourceId' => resource_id},
416
+ query_params: {'api-version' => @client.api_version},
417
+ headers: request_headers.merge(custom_headers || {}),
418
+ base_url: request_url
419
+ }
420
+ promise = @client.make_request_async(:delete, path_template, options)
421
+
422
+ promise = promise.then do |result|
423
+ http_response = result.response
424
+ status_code = http_response.status
425
+ response_content = http_response.body
426
+ unless status_code == 200 || status_code == 204
427
+ error_model = JSON.load(response_content)
428
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
429
+ end
430
+
431
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
432
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
433
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
434
+
435
+ result
436
+ end
437
+
438
+ promise.execute
439
+ end
440
+
441
+ #
442
+ # Get security assessments on all your scanned resources inside a scope
443
+ #
444
+ # @param next_page_link [String] The NextLink from the previous successful call
445
+ # to List operation.
446
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
447
+ # will be added to the HTTP request.
448
+ #
449
+ # @return [SecurityAssessmentList] operation results.
450
+ #
451
+ def list_next(next_page_link, custom_headers:nil)
452
+ response = list_next_async(next_page_link, custom_headers:custom_headers).value!
453
+ response.body unless response.nil?
454
+ end
455
+
456
+ #
457
+ # Get security assessments on all your scanned resources inside a scope
458
+ #
459
+ # @param next_page_link [String] The NextLink from the previous successful call
460
+ # to List operation.
461
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
462
+ # will be added to the HTTP request.
463
+ #
464
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
465
+ #
466
+ def list_next_with_http_info(next_page_link, custom_headers:nil)
467
+ list_next_async(next_page_link, custom_headers:custom_headers).value!
468
+ end
469
+
470
+ #
471
+ # Get security assessments on all your scanned resources inside a scope
472
+ #
473
+ # @param next_page_link [String] The NextLink from the previous successful call
474
+ # to List operation.
475
+ # @param [Hash{String => String}] A hash of custom headers that will be added
476
+ # to the HTTP request.
477
+ #
478
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
479
+ #
480
+ def list_next_async(next_page_link, custom_headers:nil)
481
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
482
+
483
+
484
+ request_headers = {}
485
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
486
+
487
+ # Set Headers
488
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
489
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
490
+ path_template = '{nextLink}'
491
+
492
+ request_url = @base_url || @client.base_url
493
+
494
+ options = {
495
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
496
+ skip_encoding_path_params: {'nextLink' => next_page_link},
497
+ headers: request_headers.merge(custom_headers || {}),
498
+ base_url: request_url
499
+ }
500
+ promise = @client.make_request_async(:get, path_template, options)
501
+
502
+ promise = promise.then do |result|
503
+ http_response = result.response
504
+ status_code = http_response.status
505
+ response_content = http_response.body
506
+ unless status_code == 200
507
+ error_model = JSON.load(response_content)
508
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
509
+ end
510
+
511
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
512
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
513
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
514
+ # Deserialize Response
515
+ if status_code == 200
516
+ begin
517
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
518
+ result_mapper = Azure::Security::Mgmt::V2020_01_01::Models::SecurityAssessmentList.mapper()
519
+ result.body = @client.deserialize(result_mapper, parsed_response)
520
+ rescue Exception => e
521
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
522
+ end
523
+ end
524
+
525
+ result
526
+ end
527
+
528
+ promise.execute
529
+ end
530
+
531
+ #
532
+ # Get security assessments on all your scanned resources inside a scope
533
+ #
534
+ # @param scope [String] Scope of the query, can be subscription
535
+ # (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or management group
536
+ # (/providers/Microsoft.Management/managementGroups/mgName).
537
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
538
+ # will be added to the HTTP request.
539
+ #
540
+ # @return [SecurityAssessmentList] which provide lazy access to pages of the
541
+ # response.
542
+ #
543
+ def list_as_lazy(scope, custom_headers:nil)
544
+ response = list_async(scope, custom_headers:custom_headers).value!
545
+ unless response.nil?
546
+ page = response.body
547
+ page.next_method = Proc.new do |next_page_link|
548
+ list_next_async(next_page_link, custom_headers:custom_headers)
549
+ end
550
+ page
551
+ end
552
+ end
553
+
554
+ end
555
+ end