azure_mgmt_policy 0.17.6 → 0.17.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +5 -5
  2. data/LICENSE.txt +20 -20
  3. data/lib/2015-10-01-preview/generated/azure_mgmt_policy.rb +0 -0
  4. data/lib/2015-10-01-preview/generated/azure_mgmt_policy/models/policy_assignment.rb +0 -0
  5. data/lib/2015-10-01-preview/generated/azure_mgmt_policy/models/policy_assignment_list_result.rb +0 -0
  6. data/lib/2015-10-01-preview/generated/azure_mgmt_policy/models/policy_definition.rb +0 -0
  7. data/lib/2015-10-01-preview/generated/azure_mgmt_policy/models/policy_definition_list_result.rb +0 -0
  8. data/lib/2015-10-01-preview/generated/azure_mgmt_policy/models/policy_type.rb +0 -0
  9. data/lib/2015-10-01-preview/generated/azure_mgmt_policy/module_definition.rb +0 -0
  10. data/lib/2015-10-01-preview/generated/azure_mgmt_policy/policy_assignments.rb +0 -0
  11. data/lib/2015-10-01-preview/generated/azure_mgmt_policy/policy_client.rb +1 -1
  12. data/lib/2015-10-01-preview/generated/azure_mgmt_policy/policy_definitions.rb +0 -0
  13. data/lib/2016-04-01/generated/azure_mgmt_policy.rb +0 -0
  14. data/lib/2016-04-01/generated/azure_mgmt_policy/models/policy_assignment.rb +0 -0
  15. data/lib/2016-04-01/generated/azure_mgmt_policy/models/policy_assignment_list_result.rb +0 -0
  16. data/lib/2016-04-01/generated/azure_mgmt_policy/models/policy_definition.rb +0 -0
  17. data/lib/2016-04-01/generated/azure_mgmt_policy/models/policy_definition_list_result.rb +0 -0
  18. data/lib/2016-04-01/generated/azure_mgmt_policy/models/policy_type.rb +0 -0
  19. data/lib/2016-04-01/generated/azure_mgmt_policy/module_definition.rb +0 -0
  20. data/lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb +0 -0
  21. data/lib/2016-04-01/generated/azure_mgmt_policy/policy_client.rb +1 -1
  22. data/lib/2016-04-01/generated/azure_mgmt_policy/policy_definitions.rb +0 -0
  23. data/lib/2016-12-01/generated/azure_mgmt_policy.rb +0 -0
  24. data/lib/2016-12-01/generated/azure_mgmt_policy/models/policy_assignment.rb +0 -0
  25. data/lib/2016-12-01/generated/azure_mgmt_policy/models/policy_assignment_list_result.rb +0 -0
  26. data/lib/2016-12-01/generated/azure_mgmt_policy/models/policy_definition.rb +0 -0
  27. data/lib/2016-12-01/generated/azure_mgmt_policy/models/policy_definition_list_result.rb +0 -0
  28. data/lib/2016-12-01/generated/azure_mgmt_policy/models/policy_mode.rb +0 -0
  29. data/lib/2016-12-01/generated/azure_mgmt_policy/models/policy_type.rb +0 -0
  30. data/lib/2016-12-01/generated/azure_mgmt_policy/module_definition.rb +0 -0
  31. data/lib/2016-12-01/generated/azure_mgmt_policy/policy_assignments.rb +0 -0
  32. data/lib/2016-12-01/generated/azure_mgmt_policy/policy_client.rb +1 -1
  33. data/lib/2016-12-01/generated/azure_mgmt_policy/policy_definitions.rb +0 -0
  34. data/lib/2017-06-01-preview/generated/azure_mgmt_policy.rb +0 -0
  35. data/lib/2017-06-01-preview/generated/azure_mgmt_policy/models/error_response.rb +0 -0
  36. data/lib/2017-06-01-preview/generated/azure_mgmt_policy/models/policy_assignment.rb +0 -0
  37. data/lib/2017-06-01-preview/generated/azure_mgmt_policy/models/policy_assignment_list_result.rb +0 -0
  38. data/lib/2017-06-01-preview/generated/azure_mgmt_policy/models/policy_definition_reference.rb +0 -0
  39. data/lib/2017-06-01-preview/generated/azure_mgmt_policy/models/policy_set_definition.rb +0 -0
  40. data/lib/2017-06-01-preview/generated/azure_mgmt_policy/models/policy_set_definition_list_result.rb +0 -0
  41. data/lib/2017-06-01-preview/generated/azure_mgmt_policy/models/policy_sku.rb +0 -0
  42. data/lib/2017-06-01-preview/generated/azure_mgmt_policy/models/policy_type.rb +0 -0
  43. data/lib/2017-06-01-preview/generated/azure_mgmt_policy/module_definition.rb +0 -0
  44. data/lib/2017-06-01-preview/generated/azure_mgmt_policy/policy_assignments.rb +0 -0
  45. data/lib/2017-06-01-preview/generated/azure_mgmt_policy/policy_client.rb +1 -1
  46. data/lib/2017-06-01-preview/generated/azure_mgmt_policy/policy_set_definitions.rb +0 -0
  47. data/lib/2018-03-01/generated/azure_mgmt_policy.rb +0 -0
  48. data/lib/2018-03-01/generated/azure_mgmt_policy/models/error_response.rb +0 -0
  49. data/lib/2018-03-01/generated/azure_mgmt_policy/models/policy_assignment.rb +0 -0
  50. data/lib/2018-03-01/generated/azure_mgmt_policy/models/policy_assignment_list_result.rb +0 -0
  51. data/lib/2018-03-01/generated/azure_mgmt_policy/models/policy_definition.rb +0 -0
  52. data/lib/2018-03-01/generated/azure_mgmt_policy/models/policy_definition_list_result.rb +0 -0
  53. data/lib/2018-03-01/generated/azure_mgmt_policy/models/policy_definition_reference.rb +0 -0
  54. data/lib/2018-03-01/generated/azure_mgmt_policy/models/policy_mode.rb +0 -0
  55. data/lib/2018-03-01/generated/azure_mgmt_policy/models/policy_set_definition.rb +0 -0
  56. data/lib/2018-03-01/generated/azure_mgmt_policy/models/policy_set_definition_list_result.rb +0 -0
  57. data/lib/2018-03-01/generated/azure_mgmt_policy/models/policy_sku.rb +0 -0
  58. data/lib/2018-03-01/generated/azure_mgmt_policy/models/policy_type.rb +0 -0
  59. data/lib/2018-03-01/generated/azure_mgmt_policy/module_definition.rb +0 -0
  60. data/lib/2018-03-01/generated/azure_mgmt_policy/policy_assignments.rb +0 -0
  61. data/lib/2018-03-01/generated/azure_mgmt_policy/policy_client.rb +1 -1
  62. data/lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb +0 -0
  63. data/lib/2018-03-01/generated/azure_mgmt_policy/policy_set_definitions.rb +0 -0
  64. data/lib/2018-05-01/generated/azure_mgmt_policy.rb +0 -0
  65. data/lib/2018-05-01/generated/azure_mgmt_policy/models/error_response.rb +0 -0
  66. data/lib/2018-05-01/generated/azure_mgmt_policy/models/identity.rb +0 -0
  67. data/lib/2018-05-01/generated/azure_mgmt_policy/models/policy_assignment.rb +0 -0
  68. data/lib/2018-05-01/generated/azure_mgmt_policy/models/policy_assignment_list_result.rb +0 -0
  69. data/lib/2018-05-01/generated/azure_mgmt_policy/models/policy_definition.rb +0 -0
  70. data/lib/2018-05-01/generated/azure_mgmt_policy/models/policy_definition_list_result.rb +0 -0
  71. data/lib/2018-05-01/generated/azure_mgmt_policy/models/policy_definition_reference.rb +0 -0
  72. data/lib/2018-05-01/generated/azure_mgmt_policy/models/policy_mode.rb +0 -0
  73. data/lib/2018-05-01/generated/azure_mgmt_policy/models/policy_set_definition.rb +0 -0
  74. data/lib/2018-05-01/generated/azure_mgmt_policy/models/policy_set_definition_list_result.rb +0 -0
  75. data/lib/2018-05-01/generated/azure_mgmt_policy/models/policy_sku.rb +0 -0
  76. data/lib/2018-05-01/generated/azure_mgmt_policy/models/policy_type.rb +0 -0
  77. data/lib/2018-05-01/generated/azure_mgmt_policy/models/resource_identity_type.rb +0 -0
  78. data/lib/2018-05-01/generated/azure_mgmt_policy/module_definition.rb +0 -0
  79. data/lib/2018-05-01/generated/azure_mgmt_policy/policy_assignments.rb +0 -0
  80. data/lib/2018-05-01/generated/azure_mgmt_policy/policy_client.rb +1 -1
  81. data/lib/2018-05-01/generated/azure_mgmt_policy/policy_definitions.rb +0 -0
  82. data/lib/2018-05-01/generated/azure_mgmt_policy/policy_set_definitions.rb +0 -0
  83. data/lib/2019-01-01/generated/azure_mgmt_policy.rb +0 -0
  84. data/lib/2019-01-01/generated/azure_mgmt_policy/models/error_response.rb +0 -0
  85. data/lib/2019-01-01/generated/azure_mgmt_policy/models/identity.rb +0 -0
  86. data/lib/2019-01-01/generated/azure_mgmt_policy/models/policy_assignment.rb +0 -0
  87. data/lib/2019-01-01/generated/azure_mgmt_policy/models/policy_assignment_list_result.rb +0 -0
  88. data/lib/2019-01-01/generated/azure_mgmt_policy/models/policy_definition.rb +0 -0
  89. data/lib/2019-01-01/generated/azure_mgmt_policy/models/policy_definition_list_result.rb +0 -0
  90. data/lib/2019-01-01/generated/azure_mgmt_policy/models/policy_definition_reference.rb +0 -0
  91. data/lib/2019-01-01/generated/azure_mgmt_policy/models/policy_set_definition.rb +0 -0
  92. data/lib/2019-01-01/generated/azure_mgmt_policy/models/policy_set_definition_list_result.rb +0 -0
  93. data/lib/2019-01-01/generated/azure_mgmt_policy/models/policy_sku.rb +0 -0
  94. data/lib/2019-01-01/generated/azure_mgmt_policy/models/policy_type.rb +0 -0
  95. data/lib/2019-01-01/generated/azure_mgmt_policy/models/resource_identity_type.rb +0 -0
  96. data/lib/2019-01-01/generated/azure_mgmt_policy/module_definition.rb +0 -0
  97. data/lib/2019-01-01/generated/azure_mgmt_policy/policy_assignments.rb +0 -0
  98. data/lib/2019-01-01/generated/azure_mgmt_policy/policy_client.rb +1 -1
  99. data/lib/2019-01-01/generated/azure_mgmt_policy/policy_definitions.rb +0 -0
  100. data/lib/2019-01-01/generated/azure_mgmt_policy/policy_set_definitions.rb +0 -0
  101. data/lib/2019-06-01/generated/azure_mgmt_policy.rb +0 -0
  102. data/lib/2019-06-01/generated/azure_mgmt_policy/models/enforcement_mode.rb +0 -0
  103. data/lib/2019-06-01/generated/azure_mgmt_policy/models/error_response.rb +0 -0
  104. data/lib/2019-06-01/generated/azure_mgmt_policy/models/identity.rb +0 -0
  105. data/lib/2019-06-01/generated/azure_mgmt_policy/models/policy_assignment.rb +0 -0
  106. data/lib/2019-06-01/generated/azure_mgmt_policy/models/policy_assignment_list_result.rb +0 -0
  107. data/lib/2019-06-01/generated/azure_mgmt_policy/models/policy_definition.rb +0 -0
  108. data/lib/2019-06-01/generated/azure_mgmt_policy/models/policy_definition_list_result.rb +0 -0
  109. data/lib/2019-06-01/generated/azure_mgmt_policy/models/policy_definition_reference.rb +0 -0
  110. data/lib/2019-06-01/generated/azure_mgmt_policy/models/policy_set_definition.rb +0 -0
  111. data/lib/2019-06-01/generated/azure_mgmt_policy/models/policy_set_definition_list_result.rb +0 -0
  112. data/lib/2019-06-01/generated/azure_mgmt_policy/models/policy_sku.rb +0 -0
  113. data/lib/2019-06-01/generated/azure_mgmt_policy/models/policy_type.rb +0 -0
  114. data/lib/2019-06-01/generated/azure_mgmt_policy/models/resource_identity_type.rb +0 -0
  115. data/lib/2019-06-01/generated/azure_mgmt_policy/module_definition.rb +0 -0
  116. data/lib/2019-06-01/generated/azure_mgmt_policy/policy_assignments.rb +0 -0
  117. data/lib/2019-06-01/generated/azure_mgmt_policy/policy_client.rb +1 -1
  118. data/lib/2019-06-01/generated/azure_mgmt_policy/policy_definitions.rb +0 -0
  119. data/lib/2019-06-01/generated/azure_mgmt_policy/policy_set_definitions.rb +0 -0
  120. data/lib/2019-09-01/generated/azure_mgmt_policy.rb +49 -0
  121. data/lib/2019-09-01/generated/azure_mgmt_policy/models/enforcement_mode.rb +16 -0
  122. data/lib/2019-09-01/generated/azure_mgmt_policy/models/error_additional_info.rb +59 -0
  123. data/lib/2019-09-01/generated/azure_mgmt_policy/models/error_response.rb +113 -0
  124. data/lib/2019-09-01/generated/azure_mgmt_policy/models/identity.rb +72 -0
  125. data/lib/2019-09-01/generated/azure_mgmt_policy/models/parameter_definitions_value.rb +92 -0
  126. data/lib/2019-09-01/generated/azure_mgmt_policy/models/parameter_definitions_value_metadata.rb +76 -0
  127. data/lib/2019-09-01/generated/azure_mgmt_policy/models/parameter_type.rb +21 -0
  128. data/lib/2019-09-01/generated/azure_mgmt_policy/models/parameter_values_value.rb +47 -0
  129. data/lib/2019-09-01/generated/azure_mgmt_policy/models/policy_assignment.rb +220 -0
  130. data/lib/2019-09-01/generated/azure_mgmt_policy/models/policy_assignment_list_result.rb +98 -0
  131. data/lib/2019-09-01/generated/azure_mgmt_policy/models/policy_definition.rb +164 -0
  132. data/lib/2019-09-01/generated/azure_mgmt_policy/models/policy_definition_group.rb +91 -0
  133. data/lib/2019-09-01/generated/azure_mgmt_policy/models/policy_definition_list_result.rb +98 -0
  134. data/lib/2019-09-01/generated/azure_mgmt_policy/models/policy_definition_reference.rb +100 -0
  135. data/lib/2019-09-01/generated/azure_mgmt_policy/models/policy_set_definition.rb +182 -0
  136. data/lib/2019-09-01/generated/azure_mgmt_policy/models/policy_set_definition_list_result.rb +99 -0
  137. data/lib/2019-09-01/generated/azure_mgmt_policy/models/policy_sku.rb +59 -0
  138. data/lib/2019-09-01/generated/azure_mgmt_policy/models/policy_type.rb +18 -0
  139. data/lib/2019-09-01/generated/azure_mgmt_policy/models/resource_identity_type.rb +16 -0
  140. data/lib/2019-09-01/generated/azure_mgmt_policy/module_definition.rb +9 -0
  141. data/lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb +1902 -0
  142. data/lib/2019-09-01/generated/azure_mgmt_policy/policy_client.rb +139 -0
  143. data/lib/2019-09-01/generated/azure_mgmt_policy/policy_definitions.rb +1391 -0
  144. data/lib/2019-09-01/generated/azure_mgmt_policy/policy_set_definitions.rb +1414 -0
  145. data/lib/azure_mgmt_policy.rb +4 -3
  146. data/lib/module_definition.rb +7 -7
  147. data/lib/profiles/latest/modules/policy_profile_module.rb +117 -117
  148. data/lib/profiles/latest/policy_latest_profile_client.rb +40 -40
  149. data/lib/profiles/latest/policy_module_definition.rb +8 -8
  150. data/lib/profiles/v2017_03_09/modules/policy_profile_module.rb +83 -83
  151. data/lib/profiles/v2017_03_09/policy_module_definition.rb +8 -8
  152. data/lib/profiles/v2017_03_09/policy_v2017_03_09_profile_client.rb +40 -40
  153. data/lib/profiles/v2018_03_01/modules/policy_profile_module.rb +87 -87
  154. data/lib/profiles/v2018_03_01/policy_module_definition.rb +8 -8
  155. data/lib/profiles/v2018_03_01/policy_v2018_03_01_profile_client.rb +40 -40
  156. data/lib/profiles/v2019_03_01_hybrid/modules/policy_profile_module.rb +87 -87
  157. data/lib/profiles/v2019_03_01_hybrid/policy_module_definition.rb +8 -8
  158. data/lib/profiles/v2019_03_01_hybrid/policy_v2019_03_01_hybrid_profile_client.rb +40 -40
  159. data/lib/version.rb +1 -1
  160. metadata +28 -3
@@ -0,0 +1,16 @@
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::Policy::Mgmt::V2019_09_01
7
+ module Models
8
+ #
9
+ # Defines values for ResourceIdentityType
10
+ #
11
+ module ResourceIdentityType
12
+ SystemAssigned = "SystemAssigned"
13
+ None = "None"
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,9 @@
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 end
7
+ module Azure::Policy end
8
+ module Azure::Policy::Mgmt end
9
+ module Azure::Policy::Mgmt::V2019_09_01 end
@@ -0,0 +1,1902 @@
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::Policy::Mgmt::V2019_09_01
7
+ #
8
+ # To manage and control access to your resources, you can define customized
9
+ # policies and assign them at a scope.
10
+ #
11
+ class PolicyAssignments
12
+ include MsRestAzure
13
+
14
+ #
15
+ # Creates and initializes a new instance of the PolicyAssignments class.
16
+ # @param client service class for accessing basic functionality.
17
+ #
18
+ def initialize(client)
19
+ @client = client
20
+ end
21
+
22
+ # @return [PolicyClient] reference to the PolicyClient
23
+ attr_reader :client
24
+
25
+ #
26
+ # Deletes a policy assignment.
27
+ #
28
+ # This operation deletes a policy assignment, given its name and the scope it
29
+ # was created in. The scope of a policy assignment is the part of its ID
30
+ # preceding
31
+ # '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
32
+ #
33
+ # @param scope [String] The scope of the policy assignment. Valid scopes are:
34
+ # management group (format:
35
+ # '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
36
+ # subscription (format: '/subscriptions/{subscriptionId}'), resource group
37
+ # (format:
38
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or
39
+ # resource (format:
40
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
41
+ # @param policy_assignment_name [String] The name of the policy assignment to
42
+ # delete.
43
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
44
+ # will be added to the HTTP request.
45
+ #
46
+ # @return [PolicyAssignment] operation results.
47
+ #
48
+ def delete(scope, policy_assignment_name, custom_headers:nil)
49
+ response = delete_async(scope, policy_assignment_name, custom_headers:custom_headers).value!
50
+ response.body unless response.nil?
51
+ end
52
+
53
+ #
54
+ # Deletes a policy assignment.
55
+ #
56
+ # This operation deletes a policy assignment, given its name and the scope it
57
+ # was created in. The scope of a policy assignment is the part of its ID
58
+ # preceding
59
+ # '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
60
+ #
61
+ # @param scope [String] The scope of the policy assignment. Valid scopes are:
62
+ # management group (format:
63
+ # '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
64
+ # subscription (format: '/subscriptions/{subscriptionId}'), resource group
65
+ # (format:
66
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or
67
+ # resource (format:
68
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
69
+ # @param policy_assignment_name [String] The name of the policy assignment to
70
+ # delete.
71
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
72
+ # will be added to the HTTP request.
73
+ #
74
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
75
+ #
76
+ def delete_with_http_info(scope, policy_assignment_name, custom_headers:nil)
77
+ delete_async(scope, policy_assignment_name, custom_headers:custom_headers).value!
78
+ end
79
+
80
+ #
81
+ # Deletes a policy assignment.
82
+ #
83
+ # This operation deletes a policy assignment, given its name and the scope it
84
+ # was created in. The scope of a policy assignment is the part of its ID
85
+ # preceding
86
+ # '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
87
+ #
88
+ # @param scope [String] The scope of the policy assignment. Valid scopes are:
89
+ # management group (format:
90
+ # '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
91
+ # subscription (format: '/subscriptions/{subscriptionId}'), resource group
92
+ # (format:
93
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or
94
+ # resource (format:
95
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
96
+ # @param policy_assignment_name [String] The name of the policy assignment to
97
+ # delete.
98
+ # @param [Hash{String => String}] A hash of custom headers that will be added
99
+ # to the HTTP request.
100
+ #
101
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
102
+ #
103
+ def delete_async(scope, policy_assignment_name, custom_headers:nil)
104
+ fail ArgumentError, 'scope is nil' if scope.nil?
105
+ fail ArgumentError, 'policy_assignment_name is nil' if policy_assignment_name.nil?
106
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
107
+
108
+
109
+ request_headers = {}
110
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
111
+
112
+ # Set Headers
113
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
114
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
115
+ path_template = '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'
116
+
117
+ request_url = @base_url || @client.base_url
118
+
119
+ options = {
120
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
121
+ path_params: {'policyAssignmentName' => policy_assignment_name},
122
+ skip_encoding_path_params: {'scope' => scope},
123
+ query_params: {'api-version' => @client.api_version},
124
+ headers: request_headers.merge(custom_headers || {}),
125
+ base_url: request_url
126
+ }
127
+ promise = @client.make_request_async(:delete, path_template, options)
128
+
129
+ promise = promise.then do |result|
130
+ http_response = result.response
131
+ status_code = http_response.status
132
+ response_content = http_response.body
133
+ unless status_code == 200 || status_code == 204
134
+ error_model = JSON.load(response_content)
135
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
136
+ end
137
+
138
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
139
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
140
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
141
+ # Deserialize Response
142
+ if status_code == 200
143
+ begin
144
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
145
+ result_mapper = Azure::Policy::Mgmt::V2019_09_01::Models::PolicyAssignment.mapper()
146
+ result.body = @client.deserialize(result_mapper, parsed_response)
147
+ rescue Exception => e
148
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
149
+ end
150
+ end
151
+
152
+ result
153
+ end
154
+
155
+ promise.execute
156
+ end
157
+
158
+ #
159
+ # Creates or updates a policy assignment.
160
+ #
161
+ # This operation creates or updates a policy assignment with the given scope
162
+ # and name. Policy assignments apply to all resources contained within their
163
+ # scope. For example, when you assign a policy at resource group scope, that
164
+ # policy applies to all resources in the group.
165
+ #
166
+ # @param scope [String] The scope of the policy assignment. Valid scopes are:
167
+ # management group (format:
168
+ # '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
169
+ # subscription (format: '/subscriptions/{subscriptionId}'), resource group
170
+ # (format:
171
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or
172
+ # resource (format:
173
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
174
+ # @param policy_assignment_name [String] The name of the policy assignment.
175
+ # @param parameters [PolicyAssignment] Parameters for the policy assignment.
176
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
177
+ # will be added to the HTTP request.
178
+ #
179
+ # @return [PolicyAssignment] operation results.
180
+ #
181
+ def create(scope, policy_assignment_name, parameters, custom_headers:nil)
182
+ response = create_async(scope, policy_assignment_name, parameters, custom_headers:custom_headers).value!
183
+ response.body unless response.nil?
184
+ end
185
+
186
+ #
187
+ # Creates or updates a policy assignment.
188
+ #
189
+ # This operation creates or updates a policy assignment with the given scope
190
+ # and name. Policy assignments apply to all resources contained within their
191
+ # scope. For example, when you assign a policy at resource group scope, that
192
+ # policy applies to all resources in the group.
193
+ #
194
+ # @param scope [String] The scope of the policy assignment. Valid scopes are:
195
+ # management group (format:
196
+ # '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
197
+ # subscription (format: '/subscriptions/{subscriptionId}'), resource group
198
+ # (format:
199
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or
200
+ # resource (format:
201
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
202
+ # @param policy_assignment_name [String] The name of the policy assignment.
203
+ # @param parameters [PolicyAssignment] Parameters for the policy assignment.
204
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
205
+ # will be added to the HTTP request.
206
+ #
207
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
208
+ #
209
+ def create_with_http_info(scope, policy_assignment_name, parameters, custom_headers:nil)
210
+ create_async(scope, policy_assignment_name, parameters, custom_headers:custom_headers).value!
211
+ end
212
+
213
+ #
214
+ # Creates or updates a policy assignment.
215
+ #
216
+ # This operation creates or updates a policy assignment with the given scope
217
+ # and name. Policy assignments apply to all resources contained within their
218
+ # scope. For example, when you assign a policy at resource group scope, that
219
+ # policy applies to all resources in the group.
220
+ #
221
+ # @param scope [String] The scope of the policy assignment. Valid scopes are:
222
+ # management group (format:
223
+ # '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
224
+ # subscription (format: '/subscriptions/{subscriptionId}'), resource group
225
+ # (format:
226
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or
227
+ # resource (format:
228
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
229
+ # @param policy_assignment_name [String] The name of the policy assignment.
230
+ # @param parameters [PolicyAssignment] Parameters for the policy assignment.
231
+ # @param [Hash{String => String}] A hash of custom headers that will be added
232
+ # to the HTTP request.
233
+ #
234
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
235
+ #
236
+ def create_async(scope, policy_assignment_name, parameters, custom_headers:nil)
237
+ fail ArgumentError, 'scope is nil' if scope.nil?
238
+ fail ArgumentError, 'policy_assignment_name is nil' if policy_assignment_name.nil?
239
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
240
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
241
+
242
+
243
+ request_headers = {}
244
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
245
+
246
+ # Set Headers
247
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
248
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
249
+
250
+ # Serialize Request
251
+ request_mapper = Azure::Policy::Mgmt::V2019_09_01::Models::PolicyAssignment.mapper()
252
+ request_content = @client.serialize(request_mapper, parameters)
253
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
254
+
255
+ path_template = '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'
256
+
257
+ request_url = @base_url || @client.base_url
258
+
259
+ options = {
260
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
261
+ path_params: {'policyAssignmentName' => policy_assignment_name},
262
+ skip_encoding_path_params: {'scope' => scope},
263
+ query_params: {'api-version' => @client.api_version},
264
+ body: request_content,
265
+ headers: request_headers.merge(custom_headers || {}),
266
+ base_url: request_url
267
+ }
268
+ promise = @client.make_request_async(:put, path_template, options)
269
+
270
+ promise = promise.then do |result|
271
+ http_response = result.response
272
+ status_code = http_response.status
273
+ response_content = http_response.body
274
+ unless status_code == 201
275
+ error_model = JSON.load(response_content)
276
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
277
+ end
278
+
279
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
280
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
281
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
282
+ # Deserialize Response
283
+ if status_code == 201
284
+ begin
285
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
286
+ result_mapper = Azure::Policy::Mgmt::V2019_09_01::Models::PolicyAssignment.mapper()
287
+ result.body = @client.deserialize(result_mapper, parsed_response)
288
+ rescue Exception => e
289
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
290
+ end
291
+ end
292
+
293
+ result
294
+ end
295
+
296
+ promise.execute
297
+ end
298
+
299
+ #
300
+ # Retrieves a policy assignment.
301
+ #
302
+ # This operation retrieves a single policy assignment, given its name and the
303
+ # scope it was created at.
304
+ #
305
+ # @param scope [String] The scope of the policy assignment. Valid scopes are:
306
+ # management group (format:
307
+ # '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
308
+ # subscription (format: '/subscriptions/{subscriptionId}'), resource group
309
+ # (format:
310
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or
311
+ # resource (format:
312
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
313
+ # @param policy_assignment_name [String] The name of the policy assignment to
314
+ # get.
315
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
316
+ # will be added to the HTTP request.
317
+ #
318
+ # @return [PolicyAssignment] operation results.
319
+ #
320
+ def get(scope, policy_assignment_name, custom_headers:nil)
321
+ response = get_async(scope, policy_assignment_name, custom_headers:custom_headers).value!
322
+ response.body unless response.nil?
323
+ end
324
+
325
+ #
326
+ # Retrieves a policy assignment.
327
+ #
328
+ # This operation retrieves a single policy assignment, given its name and the
329
+ # scope it was created at.
330
+ #
331
+ # @param scope [String] The scope of the policy assignment. Valid scopes are:
332
+ # management group (format:
333
+ # '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
334
+ # subscription (format: '/subscriptions/{subscriptionId}'), resource group
335
+ # (format:
336
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or
337
+ # resource (format:
338
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
339
+ # @param policy_assignment_name [String] The name of the policy assignment to
340
+ # get.
341
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
342
+ # will be added to the HTTP request.
343
+ #
344
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
345
+ #
346
+ def get_with_http_info(scope, policy_assignment_name, custom_headers:nil)
347
+ get_async(scope, policy_assignment_name, custom_headers:custom_headers).value!
348
+ end
349
+
350
+ #
351
+ # Retrieves a policy assignment.
352
+ #
353
+ # This operation retrieves a single policy assignment, given its name and the
354
+ # scope it was created at.
355
+ #
356
+ # @param scope [String] The scope of the policy assignment. Valid scopes are:
357
+ # management group (format:
358
+ # '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
359
+ # subscription (format: '/subscriptions/{subscriptionId}'), resource group
360
+ # (format:
361
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or
362
+ # resource (format:
363
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
364
+ # @param policy_assignment_name [String] The name of the policy assignment to
365
+ # get.
366
+ # @param [Hash{String => String}] A hash of custom headers that will be added
367
+ # to the HTTP request.
368
+ #
369
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
370
+ #
371
+ def get_async(scope, policy_assignment_name, custom_headers:nil)
372
+ fail ArgumentError, 'scope is nil' if scope.nil?
373
+ fail ArgumentError, 'policy_assignment_name is nil' if policy_assignment_name.nil?
374
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
375
+
376
+
377
+ request_headers = {}
378
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
379
+
380
+ # Set Headers
381
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
382
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
383
+ path_template = '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'
384
+
385
+ request_url = @base_url || @client.base_url
386
+
387
+ options = {
388
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
389
+ path_params: {'policyAssignmentName' => policy_assignment_name},
390
+ skip_encoding_path_params: {'scope' => scope},
391
+ query_params: {'api-version' => @client.api_version},
392
+ headers: request_headers.merge(custom_headers || {}),
393
+ base_url: request_url
394
+ }
395
+ promise = @client.make_request_async(:get, path_template, options)
396
+
397
+ promise = promise.then do |result|
398
+ http_response = result.response
399
+ status_code = http_response.status
400
+ response_content = http_response.body
401
+ unless status_code == 200
402
+ error_model = JSON.load(response_content)
403
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
404
+ end
405
+
406
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
407
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
408
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
409
+ # Deserialize Response
410
+ if status_code == 200
411
+ begin
412
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
413
+ result_mapper = Azure::Policy::Mgmt::V2019_09_01::Models::PolicyAssignment.mapper()
414
+ result.body = @client.deserialize(result_mapper, parsed_response)
415
+ rescue Exception => e
416
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
417
+ end
418
+ end
419
+
420
+ result
421
+ end
422
+
423
+ promise.execute
424
+ end
425
+
426
+ #
427
+ # Retrieves all policy assignments that apply to a resource group.
428
+ #
429
+ # This operation retrieves the list of all policy assignments associated with
430
+ # the given resource group in the given subscription that match the optional
431
+ # given $filter. Valid values for $filter are: 'atScope()' or
432
+ # 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered
433
+ # list includes all policy assignments associated with the resource group,
434
+ # including those that apply directly or apply from containing scopes, as well
435
+ # as any applied to resources contained within the resource group. If
436
+ # $filter=atScope() is provided, the returned list includes all policy
437
+ # assignments that apply to the resource group, which is everything in the
438
+ # unfiltered list except those applied to resources contained within the
439
+ # resource group. If $filter=policyDefinitionId eq '{value}' is provided, the
440
+ # returned list includes all policy assignments of the policy definition whose
441
+ # id is {value} that apply to the resource group.
442
+ #
443
+ # @param resource_group_name [String] The name of the resource group that
444
+ # contains policy assignments.
445
+ # @param filter [String] The filter to apply on the operation. Valid values for
446
+ # $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is
447
+ # not provided, no filtering is performed.
448
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
449
+ # will be added to the HTTP request.
450
+ #
451
+ # @return [Array<PolicyAssignment>] operation results.
452
+ #
453
+ def list_for_resource_group(resource_group_name, filter:nil, custom_headers:nil)
454
+ first_page = list_for_resource_group_as_lazy(resource_group_name, filter:filter, custom_headers:custom_headers)
455
+ first_page.get_all_items
456
+ end
457
+
458
+ #
459
+ # Retrieves all policy assignments that apply to a resource group.
460
+ #
461
+ # This operation retrieves the list of all policy assignments associated with
462
+ # the given resource group in the given subscription that match the optional
463
+ # given $filter. Valid values for $filter are: 'atScope()' or
464
+ # 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered
465
+ # list includes all policy assignments associated with the resource group,
466
+ # including those that apply directly or apply from containing scopes, as well
467
+ # as any applied to resources contained within the resource group. If
468
+ # $filter=atScope() is provided, the returned list includes all policy
469
+ # assignments that apply to the resource group, which is everything in the
470
+ # unfiltered list except those applied to resources contained within the
471
+ # resource group. If $filter=policyDefinitionId eq '{value}' is provided, the
472
+ # returned list includes all policy assignments of the policy definition whose
473
+ # id is {value} that apply to the resource group.
474
+ #
475
+ # @param resource_group_name [String] The name of the resource group that
476
+ # contains policy assignments.
477
+ # @param filter [String] The filter to apply on the operation. Valid values for
478
+ # $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is
479
+ # not provided, no filtering is performed.
480
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
481
+ # will be added to the HTTP request.
482
+ #
483
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
484
+ #
485
+ def list_for_resource_group_with_http_info(resource_group_name, filter:nil, custom_headers:nil)
486
+ list_for_resource_group_async(resource_group_name, filter:filter, custom_headers:custom_headers).value!
487
+ end
488
+
489
+ #
490
+ # Retrieves all policy assignments that apply to a resource group.
491
+ #
492
+ # This operation retrieves the list of all policy assignments associated with
493
+ # the given resource group in the given subscription that match the optional
494
+ # given $filter. Valid values for $filter are: 'atScope()' or
495
+ # 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered
496
+ # list includes all policy assignments associated with the resource group,
497
+ # including those that apply directly or apply from containing scopes, as well
498
+ # as any applied to resources contained within the resource group. If
499
+ # $filter=atScope() is provided, the returned list includes all policy
500
+ # assignments that apply to the resource group, which is everything in the
501
+ # unfiltered list except those applied to resources contained within the
502
+ # resource group. If $filter=policyDefinitionId eq '{value}' is provided, the
503
+ # returned list includes all policy assignments of the policy definition whose
504
+ # id is {value} that apply to the resource group.
505
+ #
506
+ # @param resource_group_name [String] The name of the resource group that
507
+ # contains policy assignments.
508
+ # @param filter [String] The filter to apply on the operation. Valid values for
509
+ # $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is
510
+ # not provided, no filtering is performed.
511
+ # @param [Hash{String => String}] A hash of custom headers that will be added
512
+ # to the HTTP request.
513
+ #
514
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
515
+ #
516
+ def list_for_resource_group_async(resource_group_name, filter:nil, custom_headers:nil)
517
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
518
+ fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MaxLength': '90'" if !resource_group_name.nil? && resource_group_name.length > 90
519
+ fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MinLength': '1'" if !resource_group_name.nil? && resource_group_name.length < 1
520
+ fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'Pattern': '^[-\w\._\(\)]+$'" if !resource_group_name.nil? && resource_group_name.match(Regexp.new('^^[-\w\._\(\)]+$$')).nil?
521
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
522
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
523
+
524
+
525
+ request_headers = {}
526
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
527
+
528
+ # Set Headers
529
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
530
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
531
+ path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'
532
+
533
+ request_url = @base_url || @client.base_url
534
+
535
+ options = {
536
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
537
+ path_params: {'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id},
538
+ query_params: {'api-version' => @client.api_version},
539
+ skip_encoding_query_params: {'$filter' => filter},
540
+ headers: request_headers.merge(custom_headers || {}),
541
+ base_url: request_url
542
+ }
543
+ promise = @client.make_request_async(:get, path_template, options)
544
+
545
+ promise = promise.then do |result|
546
+ http_response = result.response
547
+ status_code = http_response.status
548
+ response_content = http_response.body
549
+ unless status_code == 200
550
+ error_model = JSON.load(response_content)
551
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
552
+ end
553
+
554
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
555
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
556
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
557
+ # Deserialize Response
558
+ if status_code == 200
559
+ begin
560
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
561
+ result_mapper = Azure::Policy::Mgmt::V2019_09_01::Models::PolicyAssignmentListResult.mapper()
562
+ result.body = @client.deserialize(result_mapper, parsed_response)
563
+ rescue Exception => e
564
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
565
+ end
566
+ end
567
+
568
+ result
569
+ end
570
+
571
+ promise.execute
572
+ end
573
+
574
+ #
575
+ # Retrieves all policy assignments that apply to a resource.
576
+ #
577
+ # This operation retrieves the list of all policy assignments associated with
578
+ # the specified resource in the given resource group and subscription that
579
+ # match the optional given $filter. Valid values for $filter are: 'atScope()'
580
+ # or 'policyDefinitionId eq '{value}''. If $filter is not provided, the
581
+ # unfiltered list includes all policy assignments associated with the resource,
582
+ # including those that apply directly or from all containing scopes, as well as
583
+ # any applied to resources contained within the resource. If $filter=atScope()
584
+ # is provided, the returned list includes all policy assignments that apply to
585
+ # the resource, which is everything in the unfiltered list except those applied
586
+ # to resources contained within the resource. If $filter=policyDefinitionId eq
587
+ # '{value}' is provided, the returned list includes all policy assignments of
588
+ # the policy definition whose id is {value} that apply to the resource. Three
589
+ # parameters plus the resource name are used to identify a specific resource.
590
+ # If the resource is not part of a parent resource (the more common case), the
591
+ # parent resource path should not be provided (or provided as ''). For example
592
+ # a web app could be specified as ({resourceProviderNamespace} ==
593
+ # 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites',
594
+ # {resourceName} == 'MyWebApp'). If the resource is part of a parent resource,
595
+ # then all parameters should be provided. For example a virtual machine DNS
596
+ # name could be specified as ({resourceProviderNamespace} ==
597
+ # 'Microsoft.Compute', {parentResourcePath} ==
598
+ # 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames',
599
+ # {resourceName} == 'MyComputerName'). A convenient alternative to providing
600
+ # the namespace and type name separately is to provide both in the
601
+ # {resourceType} parameter, format: ({resourceProviderNamespace} == '',
602
+ # {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites',
603
+ # {resourceName} == 'MyWebApp').
604
+ #
605
+ # @param resource_group_name [String] The name of the resource group containing
606
+ # the resource.
607
+ # @param resource_provider_namespace [String] The namespace of the resource
608
+ # provider. For example, the namespace of a virtual machine is
609
+ # Microsoft.Compute (from Microsoft.Compute/virtualMachines)
610
+ # @param parent_resource_path [String] The parent resource path. Use empty
611
+ # string if there is none.
612
+ # @param resource_type [String] The resource type name. For example the type
613
+ # name of a web app is 'sites' (from Microsoft.Web/sites).
614
+ # @param resource_name [String] The name of the resource.
615
+ # @param filter [String] The filter to apply on the operation. Valid values for
616
+ # $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is
617
+ # not provided, no filtering is performed.
618
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
619
+ # will be added to the HTTP request.
620
+ #
621
+ # @return [Array<PolicyAssignment>] operation results.
622
+ #
623
+ def list_for_resource(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter:nil, custom_headers:nil)
624
+ first_page = list_for_resource_as_lazy(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter:filter, custom_headers:custom_headers)
625
+ first_page.get_all_items
626
+ end
627
+
628
+ #
629
+ # Retrieves all policy assignments that apply to a resource.
630
+ #
631
+ # This operation retrieves the list of all policy assignments associated with
632
+ # the specified resource in the given resource group and subscription that
633
+ # match the optional given $filter. Valid values for $filter are: 'atScope()'
634
+ # or 'policyDefinitionId eq '{value}''. If $filter is not provided, the
635
+ # unfiltered list includes all policy assignments associated with the resource,
636
+ # including those that apply directly or from all containing scopes, as well as
637
+ # any applied to resources contained within the resource. If $filter=atScope()
638
+ # is provided, the returned list includes all policy assignments that apply to
639
+ # the resource, which is everything in the unfiltered list except those applied
640
+ # to resources contained within the resource. If $filter=policyDefinitionId eq
641
+ # '{value}' is provided, the returned list includes all policy assignments of
642
+ # the policy definition whose id is {value} that apply to the resource. Three
643
+ # parameters plus the resource name are used to identify a specific resource.
644
+ # If the resource is not part of a parent resource (the more common case), the
645
+ # parent resource path should not be provided (or provided as ''). For example
646
+ # a web app could be specified as ({resourceProviderNamespace} ==
647
+ # 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites',
648
+ # {resourceName} == 'MyWebApp'). If the resource is part of a parent resource,
649
+ # then all parameters should be provided. For example a virtual machine DNS
650
+ # name could be specified as ({resourceProviderNamespace} ==
651
+ # 'Microsoft.Compute', {parentResourcePath} ==
652
+ # 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames',
653
+ # {resourceName} == 'MyComputerName'). A convenient alternative to providing
654
+ # the namespace and type name separately is to provide both in the
655
+ # {resourceType} parameter, format: ({resourceProviderNamespace} == '',
656
+ # {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites',
657
+ # {resourceName} == 'MyWebApp').
658
+ #
659
+ # @param resource_group_name [String] The name of the resource group containing
660
+ # the resource.
661
+ # @param resource_provider_namespace [String] The namespace of the resource
662
+ # provider. For example, the namespace of a virtual machine is
663
+ # Microsoft.Compute (from Microsoft.Compute/virtualMachines)
664
+ # @param parent_resource_path [String] The parent resource path. Use empty
665
+ # string if there is none.
666
+ # @param resource_type [String] The resource type name. For example the type
667
+ # name of a web app is 'sites' (from Microsoft.Web/sites).
668
+ # @param resource_name [String] The name of the resource.
669
+ # @param filter [String] The filter to apply on the operation. Valid values for
670
+ # $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is
671
+ # not provided, no filtering is performed.
672
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
673
+ # will be added to the HTTP request.
674
+ #
675
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
676
+ #
677
+ def list_for_resource_with_http_info(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter:nil, custom_headers:nil)
678
+ list_for_resource_async(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter:filter, custom_headers:custom_headers).value!
679
+ end
680
+
681
+ #
682
+ # Retrieves all policy assignments that apply to a resource.
683
+ #
684
+ # This operation retrieves the list of all policy assignments associated with
685
+ # the specified resource in the given resource group and subscription that
686
+ # match the optional given $filter. Valid values for $filter are: 'atScope()'
687
+ # or 'policyDefinitionId eq '{value}''. If $filter is not provided, the
688
+ # unfiltered list includes all policy assignments associated with the resource,
689
+ # including those that apply directly or from all containing scopes, as well as
690
+ # any applied to resources contained within the resource. If $filter=atScope()
691
+ # is provided, the returned list includes all policy assignments that apply to
692
+ # the resource, which is everything in the unfiltered list except those applied
693
+ # to resources contained within the resource. If $filter=policyDefinitionId eq
694
+ # '{value}' is provided, the returned list includes all policy assignments of
695
+ # the policy definition whose id is {value} that apply to the resource. Three
696
+ # parameters plus the resource name are used to identify a specific resource.
697
+ # If the resource is not part of a parent resource (the more common case), the
698
+ # parent resource path should not be provided (or provided as ''). For example
699
+ # a web app could be specified as ({resourceProviderNamespace} ==
700
+ # 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites',
701
+ # {resourceName} == 'MyWebApp'). If the resource is part of a parent resource,
702
+ # then all parameters should be provided. For example a virtual machine DNS
703
+ # name could be specified as ({resourceProviderNamespace} ==
704
+ # 'Microsoft.Compute', {parentResourcePath} ==
705
+ # 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames',
706
+ # {resourceName} == 'MyComputerName'). A convenient alternative to providing
707
+ # the namespace and type name separately is to provide both in the
708
+ # {resourceType} parameter, format: ({resourceProviderNamespace} == '',
709
+ # {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites',
710
+ # {resourceName} == 'MyWebApp').
711
+ #
712
+ # @param resource_group_name [String] The name of the resource group containing
713
+ # the resource.
714
+ # @param resource_provider_namespace [String] The namespace of the resource
715
+ # provider. For example, the namespace of a virtual machine is
716
+ # Microsoft.Compute (from Microsoft.Compute/virtualMachines)
717
+ # @param parent_resource_path [String] The parent resource path. Use empty
718
+ # string if there is none.
719
+ # @param resource_type [String] The resource type name. For example the type
720
+ # name of a web app is 'sites' (from Microsoft.Web/sites).
721
+ # @param resource_name [String] The name of the resource.
722
+ # @param filter [String] The filter to apply on the operation. Valid values for
723
+ # $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is
724
+ # not provided, no filtering is performed.
725
+ # @param [Hash{String => String}] A hash of custom headers that will be added
726
+ # to the HTTP request.
727
+ #
728
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
729
+ #
730
+ def list_for_resource_async(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter:nil, custom_headers:nil)
731
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
732
+ fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MaxLength': '90'" if !resource_group_name.nil? && resource_group_name.length > 90
733
+ fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MinLength': '1'" if !resource_group_name.nil? && resource_group_name.length < 1
734
+ fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'Pattern': '^[-\w\._\(\)]+$'" if !resource_group_name.nil? && resource_group_name.match(Regexp.new('^^[-\w\._\(\)]+$$')).nil?
735
+ fail ArgumentError, 'resource_provider_namespace is nil' if resource_provider_namespace.nil?
736
+ fail ArgumentError, 'parent_resource_path is nil' if parent_resource_path.nil?
737
+ fail ArgumentError, 'resource_type is nil' if resource_type.nil?
738
+ fail ArgumentError, 'resource_name is nil' if resource_name.nil?
739
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
740
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
741
+
742
+
743
+ request_headers = {}
744
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
745
+
746
+ # Set Headers
747
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
748
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
749
+ path_template = 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments'
750
+
751
+ request_url = @base_url || @client.base_url
752
+
753
+ options = {
754
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
755
+ path_params: {'resourceGroupName' => resource_group_name,'resourceProviderNamespace' => resource_provider_namespace,'resourceName' => resource_name,'subscriptionId' => @client.subscription_id},
756
+ skip_encoding_path_params: {'parentResourcePath' => parent_resource_path,'resourceType' => resource_type},
757
+ query_params: {'$filter' => filter,'api-version' => @client.api_version},
758
+ headers: request_headers.merge(custom_headers || {}),
759
+ base_url: request_url
760
+ }
761
+ promise = @client.make_request_async(:get, path_template, options)
762
+
763
+ promise = promise.then do |result|
764
+ http_response = result.response
765
+ status_code = http_response.status
766
+ response_content = http_response.body
767
+ unless status_code == 200
768
+ error_model = JSON.load(response_content)
769
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
770
+ end
771
+
772
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
773
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
774
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
775
+ # Deserialize Response
776
+ if status_code == 200
777
+ begin
778
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
779
+ result_mapper = Azure::Policy::Mgmt::V2019_09_01::Models::PolicyAssignmentListResult.mapper()
780
+ result.body = @client.deserialize(result_mapper, parsed_response)
781
+ rescue Exception => e
782
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
783
+ end
784
+ end
785
+
786
+ result
787
+ end
788
+
789
+ promise.execute
790
+ end
791
+
792
+ #
793
+ # Retrieves all policy assignments that apply to a subscription.
794
+ #
795
+ # This operation retrieves the list of all policy assignments associated with
796
+ # the given subscription that match the optional given $filter. Valid values
797
+ # for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter
798
+ # is not provided, the unfiltered list includes all policy assignments
799
+ # associated with the subscription, including those that apply directly or from
800
+ # management groups that contain the given subscription, as well as any applied
801
+ # to objects contained within the subscription. If $filter=atScope() is
802
+ # provided, the returned list includes all policy assignments that apply to the
803
+ # subscription, which is everything in the unfiltered list except those applied
804
+ # to objects contained within the subscription. If $filter=policyDefinitionId
805
+ # eq '{value}' is provided, the returned list includes all policy assignments
806
+ # of the policy definition whose id is {value}.
807
+ #
808
+ # @param filter [String] The filter to apply on the operation. Valid values for
809
+ # $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is
810
+ # not provided, no filtering is performed.
811
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
812
+ # will be added to the HTTP request.
813
+ #
814
+ # @return [Array<PolicyAssignment>] operation results.
815
+ #
816
+ def list(filter:nil, custom_headers:nil)
817
+ first_page = list_as_lazy(filter:filter, custom_headers:custom_headers)
818
+ first_page.get_all_items
819
+ end
820
+
821
+ #
822
+ # Retrieves all policy assignments that apply to a subscription.
823
+ #
824
+ # This operation retrieves the list of all policy assignments associated with
825
+ # the given subscription that match the optional given $filter. Valid values
826
+ # for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter
827
+ # is not provided, the unfiltered list includes all policy assignments
828
+ # associated with the subscription, including those that apply directly or from
829
+ # management groups that contain the given subscription, as well as any applied
830
+ # to objects contained within the subscription. If $filter=atScope() is
831
+ # provided, the returned list includes all policy assignments that apply to the
832
+ # subscription, which is everything in the unfiltered list except those applied
833
+ # to objects contained within the subscription. If $filter=policyDefinitionId
834
+ # eq '{value}' is provided, the returned list includes all policy assignments
835
+ # of the policy definition whose id is {value}.
836
+ #
837
+ # @param filter [String] The filter to apply on the operation. Valid values for
838
+ # $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is
839
+ # not provided, no filtering is performed.
840
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
841
+ # will be added to the HTTP request.
842
+ #
843
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
844
+ #
845
+ def list_with_http_info(filter:nil, custom_headers:nil)
846
+ list_async(filter:filter, custom_headers:custom_headers).value!
847
+ end
848
+
849
+ #
850
+ # Retrieves all policy assignments that apply to a subscription.
851
+ #
852
+ # This operation retrieves the list of all policy assignments associated with
853
+ # the given subscription that match the optional given $filter. Valid values
854
+ # for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter
855
+ # is not provided, the unfiltered list includes all policy assignments
856
+ # associated with the subscription, including those that apply directly or from
857
+ # management groups that contain the given subscription, as well as any applied
858
+ # to objects contained within the subscription. If $filter=atScope() is
859
+ # provided, the returned list includes all policy assignments that apply to the
860
+ # subscription, which is everything in the unfiltered list except those applied
861
+ # to objects contained within the subscription. If $filter=policyDefinitionId
862
+ # eq '{value}' is provided, the returned list includes all policy assignments
863
+ # of the policy definition whose id is {value}.
864
+ #
865
+ # @param filter [String] The filter to apply on the operation. Valid values for
866
+ # $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is
867
+ # not provided, no filtering is performed.
868
+ # @param [Hash{String => String}] A hash of custom headers that will be added
869
+ # to the HTTP request.
870
+ #
871
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
872
+ #
873
+ def list_async(filter:nil, custom_headers:nil)
874
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
875
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
876
+
877
+
878
+ request_headers = {}
879
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
880
+
881
+ # Set Headers
882
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
883
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
884
+ path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments'
885
+
886
+ request_url = @base_url || @client.base_url
887
+
888
+ options = {
889
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
890
+ path_params: {'subscriptionId' => @client.subscription_id},
891
+ query_params: {'$filter' => filter,'api-version' => @client.api_version},
892
+ headers: request_headers.merge(custom_headers || {}),
893
+ base_url: request_url
894
+ }
895
+ promise = @client.make_request_async(:get, path_template, options)
896
+
897
+ promise = promise.then do |result|
898
+ http_response = result.response
899
+ status_code = http_response.status
900
+ response_content = http_response.body
901
+ unless status_code == 200
902
+ error_model = JSON.load(response_content)
903
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
904
+ end
905
+
906
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
907
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
908
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
909
+ # Deserialize Response
910
+ if status_code == 200
911
+ begin
912
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
913
+ result_mapper = Azure::Policy::Mgmt::V2019_09_01::Models::PolicyAssignmentListResult.mapper()
914
+ result.body = @client.deserialize(result_mapper, parsed_response)
915
+ rescue Exception => e
916
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
917
+ end
918
+ end
919
+
920
+ result
921
+ end
922
+
923
+ promise.execute
924
+ end
925
+
926
+ #
927
+ # Deletes a policy assignment.
928
+ #
929
+ # This operation deletes the policy with the given ID. Policy assignment IDs
930
+ # have this format:
931
+ # '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
932
+ # Valid formats for {scope} are:
933
+ # '/providers/Microsoft.Management/managementGroups/{managementGroup}'
934
+ # (management group), '/subscriptions/{subscriptionId}' (subscription),
935
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}'
936
+ # (resource group), or
937
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
938
+ # (resource).
939
+ #
940
+ # @param policy_assignment_id [String] The ID of the policy assignment to
941
+ # delete. Use the format
942
+ # '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
943
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
944
+ # will be added to the HTTP request.
945
+ #
946
+ # @return [PolicyAssignment] operation results.
947
+ #
948
+ def delete_by_id(policy_assignment_id, custom_headers:nil)
949
+ response = delete_by_id_async(policy_assignment_id, custom_headers:custom_headers).value!
950
+ response.body unless response.nil?
951
+ end
952
+
953
+ #
954
+ # Deletes a policy assignment.
955
+ #
956
+ # This operation deletes the policy with the given ID. Policy assignment IDs
957
+ # have this format:
958
+ # '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
959
+ # Valid formats for {scope} are:
960
+ # '/providers/Microsoft.Management/managementGroups/{managementGroup}'
961
+ # (management group), '/subscriptions/{subscriptionId}' (subscription),
962
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}'
963
+ # (resource group), or
964
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
965
+ # (resource).
966
+ #
967
+ # @param policy_assignment_id [String] The ID of the policy assignment to
968
+ # delete. Use the format
969
+ # '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
970
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
971
+ # will be added to the HTTP request.
972
+ #
973
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
974
+ #
975
+ def delete_by_id_with_http_info(policy_assignment_id, custom_headers:nil)
976
+ delete_by_id_async(policy_assignment_id, custom_headers:custom_headers).value!
977
+ end
978
+
979
+ #
980
+ # Deletes a policy assignment.
981
+ #
982
+ # This operation deletes the policy with the given ID. Policy assignment IDs
983
+ # have this format:
984
+ # '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
985
+ # Valid formats for {scope} are:
986
+ # '/providers/Microsoft.Management/managementGroups/{managementGroup}'
987
+ # (management group), '/subscriptions/{subscriptionId}' (subscription),
988
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}'
989
+ # (resource group), or
990
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
991
+ # (resource).
992
+ #
993
+ # @param policy_assignment_id [String] The ID of the policy assignment to
994
+ # delete. Use the format
995
+ # '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
996
+ # @param [Hash{String => String}] A hash of custom headers that will be added
997
+ # to the HTTP request.
998
+ #
999
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1000
+ #
1001
+ def delete_by_id_async(policy_assignment_id, custom_headers:nil)
1002
+ fail ArgumentError, 'policy_assignment_id is nil' if policy_assignment_id.nil?
1003
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
1004
+
1005
+
1006
+ request_headers = {}
1007
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1008
+
1009
+ # Set Headers
1010
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1011
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1012
+ path_template = '{policyAssignmentId}'
1013
+
1014
+ request_url = @base_url || @client.base_url
1015
+
1016
+ options = {
1017
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1018
+ skip_encoding_path_params: {'policyAssignmentId' => policy_assignment_id},
1019
+ query_params: {'api-version' => @client.api_version},
1020
+ headers: request_headers.merge(custom_headers || {}),
1021
+ base_url: request_url
1022
+ }
1023
+ promise = @client.make_request_async(:delete, path_template, options)
1024
+
1025
+ promise = promise.then do |result|
1026
+ http_response = result.response
1027
+ status_code = http_response.status
1028
+ response_content = http_response.body
1029
+ unless status_code == 200 || status_code == 204
1030
+ error_model = JSON.load(response_content)
1031
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
1032
+ end
1033
+
1034
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1035
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
1036
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
1037
+ # Deserialize Response
1038
+ if status_code == 200
1039
+ begin
1040
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1041
+ result_mapper = Azure::Policy::Mgmt::V2019_09_01::Models::PolicyAssignment.mapper()
1042
+ result.body = @client.deserialize(result_mapper, parsed_response)
1043
+ rescue Exception => e
1044
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1045
+ end
1046
+ end
1047
+
1048
+ result
1049
+ end
1050
+
1051
+ promise.execute
1052
+ end
1053
+
1054
+ #
1055
+ # Creates or updates a policy assignment.
1056
+ #
1057
+ # This operation creates or updates the policy assignment with the given ID.
1058
+ # Policy assignments made on a scope apply to all resources contained in that
1059
+ # scope. For example, when you assign a policy to a resource group that policy
1060
+ # applies to all resources in the group. Policy assignment IDs have this
1061
+ # format:
1062
+ # '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
1063
+ # Valid scopes are: management group (format:
1064
+ # '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
1065
+ # subscription (format: '/subscriptions/{subscriptionId}'), resource group
1066
+ # (format:
1067
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or
1068
+ # resource (format:
1069
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'.
1070
+ #
1071
+ # @param policy_assignment_id [String] The ID of the policy assignment to
1072
+ # create. Use the format
1073
+ # '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
1074
+ # @param parameters [PolicyAssignment] Parameters for policy assignment.
1075
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1076
+ # will be added to the HTTP request.
1077
+ #
1078
+ # @return [PolicyAssignment] operation results.
1079
+ #
1080
+ def create_by_id(policy_assignment_id, parameters, custom_headers:nil)
1081
+ response = create_by_id_async(policy_assignment_id, parameters, custom_headers:custom_headers).value!
1082
+ response.body unless response.nil?
1083
+ end
1084
+
1085
+ #
1086
+ # Creates or updates a policy assignment.
1087
+ #
1088
+ # This operation creates or updates the policy assignment with the given ID.
1089
+ # Policy assignments made on a scope apply to all resources contained in that
1090
+ # scope. For example, when you assign a policy to a resource group that policy
1091
+ # applies to all resources in the group. Policy assignment IDs have this
1092
+ # format:
1093
+ # '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
1094
+ # Valid scopes are: management group (format:
1095
+ # '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
1096
+ # subscription (format: '/subscriptions/{subscriptionId}'), resource group
1097
+ # (format:
1098
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or
1099
+ # resource (format:
1100
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'.
1101
+ #
1102
+ # @param policy_assignment_id [String] The ID of the policy assignment to
1103
+ # create. Use the format
1104
+ # '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
1105
+ # @param parameters [PolicyAssignment] Parameters for policy assignment.
1106
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1107
+ # will be added to the HTTP request.
1108
+ #
1109
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1110
+ #
1111
+ def create_by_id_with_http_info(policy_assignment_id, parameters, custom_headers:nil)
1112
+ create_by_id_async(policy_assignment_id, parameters, custom_headers:custom_headers).value!
1113
+ end
1114
+
1115
+ #
1116
+ # Creates or updates a policy assignment.
1117
+ #
1118
+ # This operation creates or updates the policy assignment with the given ID.
1119
+ # Policy assignments made on a scope apply to all resources contained in that
1120
+ # scope. For example, when you assign a policy to a resource group that policy
1121
+ # applies to all resources in the group. Policy assignment IDs have this
1122
+ # format:
1123
+ # '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
1124
+ # Valid scopes are: management group (format:
1125
+ # '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
1126
+ # subscription (format: '/subscriptions/{subscriptionId}'), resource group
1127
+ # (format:
1128
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or
1129
+ # resource (format:
1130
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'.
1131
+ #
1132
+ # @param policy_assignment_id [String] The ID of the policy assignment to
1133
+ # create. Use the format
1134
+ # '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
1135
+ # @param parameters [PolicyAssignment] Parameters for policy assignment.
1136
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1137
+ # to the HTTP request.
1138
+ #
1139
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1140
+ #
1141
+ def create_by_id_async(policy_assignment_id, parameters, custom_headers:nil)
1142
+ fail ArgumentError, 'policy_assignment_id is nil' if policy_assignment_id.nil?
1143
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
1144
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
1145
+
1146
+
1147
+ request_headers = {}
1148
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1149
+
1150
+ # Set Headers
1151
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1152
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1153
+
1154
+ # Serialize Request
1155
+ request_mapper = Azure::Policy::Mgmt::V2019_09_01::Models::PolicyAssignment.mapper()
1156
+ request_content = @client.serialize(request_mapper, parameters)
1157
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
1158
+
1159
+ path_template = '{policyAssignmentId}'
1160
+
1161
+ request_url = @base_url || @client.base_url
1162
+
1163
+ options = {
1164
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1165
+ skip_encoding_path_params: {'policyAssignmentId' => policy_assignment_id},
1166
+ query_params: {'api-version' => @client.api_version},
1167
+ body: request_content,
1168
+ headers: request_headers.merge(custom_headers || {}),
1169
+ base_url: request_url
1170
+ }
1171
+ promise = @client.make_request_async(:put, path_template, options)
1172
+
1173
+ promise = promise.then do |result|
1174
+ http_response = result.response
1175
+ status_code = http_response.status
1176
+ response_content = http_response.body
1177
+ unless status_code == 201
1178
+ error_model = JSON.load(response_content)
1179
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
1180
+ end
1181
+
1182
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1183
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
1184
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
1185
+ # Deserialize Response
1186
+ if status_code == 201
1187
+ begin
1188
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1189
+ result_mapper = Azure::Policy::Mgmt::V2019_09_01::Models::PolicyAssignment.mapper()
1190
+ result.body = @client.deserialize(result_mapper, parsed_response)
1191
+ rescue Exception => e
1192
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1193
+ end
1194
+ end
1195
+
1196
+ result
1197
+ end
1198
+
1199
+ promise.execute
1200
+ end
1201
+
1202
+ #
1203
+ # Retrieves the policy assignment with the given ID.
1204
+ #
1205
+ # The operation retrieves the policy assignment with the given ID. Policy
1206
+ # assignment IDs have this format:
1207
+ # '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
1208
+ # Valid scopes are: management group (format:
1209
+ # '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
1210
+ # subscription (format: '/subscriptions/{subscriptionId}'), resource group
1211
+ # (format:
1212
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or
1213
+ # resource (format:
1214
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'.
1215
+ #
1216
+ # @param policy_assignment_id [String] The ID of the policy assignment to get.
1217
+ # Use the format
1218
+ # '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
1219
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1220
+ # will be added to the HTTP request.
1221
+ #
1222
+ # @return [PolicyAssignment] operation results.
1223
+ #
1224
+ def get_by_id(policy_assignment_id, custom_headers:nil)
1225
+ response = get_by_id_async(policy_assignment_id, custom_headers:custom_headers).value!
1226
+ response.body unless response.nil?
1227
+ end
1228
+
1229
+ #
1230
+ # Retrieves the policy assignment with the given ID.
1231
+ #
1232
+ # The operation retrieves the policy assignment with the given ID. Policy
1233
+ # assignment IDs have this format:
1234
+ # '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
1235
+ # Valid scopes are: management group (format:
1236
+ # '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
1237
+ # subscription (format: '/subscriptions/{subscriptionId}'), resource group
1238
+ # (format:
1239
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or
1240
+ # resource (format:
1241
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'.
1242
+ #
1243
+ # @param policy_assignment_id [String] The ID of the policy assignment to get.
1244
+ # Use the format
1245
+ # '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
1246
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1247
+ # will be added to the HTTP request.
1248
+ #
1249
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1250
+ #
1251
+ def get_by_id_with_http_info(policy_assignment_id, custom_headers:nil)
1252
+ get_by_id_async(policy_assignment_id, custom_headers:custom_headers).value!
1253
+ end
1254
+
1255
+ #
1256
+ # Retrieves the policy assignment with the given ID.
1257
+ #
1258
+ # The operation retrieves the policy assignment with the given ID. Policy
1259
+ # assignment IDs have this format:
1260
+ # '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
1261
+ # Valid scopes are: management group (format:
1262
+ # '/providers/Microsoft.Management/managementGroups/{managementGroup}'),
1263
+ # subscription (format: '/subscriptions/{subscriptionId}'), resource group
1264
+ # (format:
1265
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or
1266
+ # resource (format:
1267
+ # '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'.
1268
+ #
1269
+ # @param policy_assignment_id [String] The ID of the policy assignment to get.
1270
+ # Use the format
1271
+ # '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
1272
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1273
+ # to the HTTP request.
1274
+ #
1275
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1276
+ #
1277
+ def get_by_id_async(policy_assignment_id, custom_headers:nil)
1278
+ fail ArgumentError, 'policy_assignment_id is nil' if policy_assignment_id.nil?
1279
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
1280
+
1281
+
1282
+ request_headers = {}
1283
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1284
+
1285
+ # Set Headers
1286
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1287
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1288
+ path_template = '{policyAssignmentId}'
1289
+
1290
+ request_url = @base_url || @client.base_url
1291
+
1292
+ options = {
1293
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1294
+ skip_encoding_path_params: {'policyAssignmentId' => policy_assignment_id},
1295
+ query_params: {'api-version' => @client.api_version},
1296
+ headers: request_headers.merge(custom_headers || {}),
1297
+ base_url: request_url
1298
+ }
1299
+ promise = @client.make_request_async(:get, path_template, options)
1300
+
1301
+ promise = promise.then do |result|
1302
+ http_response = result.response
1303
+ status_code = http_response.status
1304
+ response_content = http_response.body
1305
+ unless status_code == 200
1306
+ error_model = JSON.load(response_content)
1307
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
1308
+ end
1309
+
1310
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1311
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
1312
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
1313
+ # Deserialize Response
1314
+ if status_code == 200
1315
+ begin
1316
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1317
+ result_mapper = Azure::Policy::Mgmt::V2019_09_01::Models::PolicyAssignment.mapper()
1318
+ result.body = @client.deserialize(result_mapper, parsed_response)
1319
+ rescue Exception => e
1320
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1321
+ end
1322
+ end
1323
+
1324
+ result
1325
+ end
1326
+
1327
+ promise.execute
1328
+ end
1329
+
1330
+ #
1331
+ # Retrieves all policy assignments that apply to a resource group.
1332
+ #
1333
+ # This operation retrieves the list of all policy assignments associated with
1334
+ # the given resource group in the given subscription that match the optional
1335
+ # given $filter. Valid values for $filter are: 'atScope()' or
1336
+ # 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered
1337
+ # list includes all policy assignments associated with the resource group,
1338
+ # including those that apply directly or apply from containing scopes, as well
1339
+ # as any applied to resources contained within the resource group. If
1340
+ # $filter=atScope() is provided, the returned list includes all policy
1341
+ # assignments that apply to the resource group, which is everything in the
1342
+ # unfiltered list except those applied to resources contained within the
1343
+ # resource group. If $filter=policyDefinitionId eq '{value}' is provided, the
1344
+ # returned list includes all policy assignments of the policy definition whose
1345
+ # id is {value} that apply to the resource group.
1346
+ #
1347
+ # @param next_page_link [String] The NextLink from the previous successful call
1348
+ # to List operation.
1349
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1350
+ # will be added to the HTTP request.
1351
+ #
1352
+ # @return [PolicyAssignmentListResult] operation results.
1353
+ #
1354
+ def list_for_resource_group_next(next_page_link, custom_headers:nil)
1355
+ response = list_for_resource_group_next_async(next_page_link, custom_headers:custom_headers).value!
1356
+ response.body unless response.nil?
1357
+ end
1358
+
1359
+ #
1360
+ # Retrieves all policy assignments that apply to a resource group.
1361
+ #
1362
+ # This operation retrieves the list of all policy assignments associated with
1363
+ # the given resource group in the given subscription that match the optional
1364
+ # given $filter. Valid values for $filter are: 'atScope()' or
1365
+ # 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered
1366
+ # list includes all policy assignments associated with the resource group,
1367
+ # including those that apply directly or apply from containing scopes, as well
1368
+ # as any applied to resources contained within the resource group. If
1369
+ # $filter=atScope() is provided, the returned list includes all policy
1370
+ # assignments that apply to the resource group, which is everything in the
1371
+ # unfiltered list except those applied to resources contained within the
1372
+ # resource group. If $filter=policyDefinitionId eq '{value}' is provided, the
1373
+ # returned list includes all policy assignments of the policy definition whose
1374
+ # id is {value} that apply to the resource group.
1375
+ #
1376
+ # @param next_page_link [String] The NextLink from the previous successful call
1377
+ # to List operation.
1378
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1379
+ # will be added to the HTTP request.
1380
+ #
1381
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1382
+ #
1383
+ def list_for_resource_group_next_with_http_info(next_page_link, custom_headers:nil)
1384
+ list_for_resource_group_next_async(next_page_link, custom_headers:custom_headers).value!
1385
+ end
1386
+
1387
+ #
1388
+ # Retrieves all policy assignments that apply to a resource group.
1389
+ #
1390
+ # This operation retrieves the list of all policy assignments associated with
1391
+ # the given resource group in the given subscription that match the optional
1392
+ # given $filter. Valid values for $filter are: 'atScope()' or
1393
+ # 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered
1394
+ # list includes all policy assignments associated with the resource group,
1395
+ # including those that apply directly or apply from containing scopes, as well
1396
+ # as any applied to resources contained within the resource group. If
1397
+ # $filter=atScope() is provided, the returned list includes all policy
1398
+ # assignments that apply to the resource group, which is everything in the
1399
+ # unfiltered list except those applied to resources contained within the
1400
+ # resource group. If $filter=policyDefinitionId eq '{value}' is provided, the
1401
+ # returned list includes all policy assignments of the policy definition whose
1402
+ # id is {value} that apply to the resource group.
1403
+ #
1404
+ # @param next_page_link [String] The NextLink from the previous successful call
1405
+ # to List operation.
1406
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1407
+ # to the HTTP request.
1408
+ #
1409
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1410
+ #
1411
+ def list_for_resource_group_next_async(next_page_link, custom_headers:nil)
1412
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
1413
+
1414
+
1415
+ request_headers = {}
1416
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1417
+
1418
+ # Set Headers
1419
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1420
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1421
+ path_template = '{nextLink}'
1422
+
1423
+ request_url = @base_url || @client.base_url
1424
+
1425
+ options = {
1426
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1427
+ skip_encoding_path_params: {'nextLink' => next_page_link},
1428
+ headers: request_headers.merge(custom_headers || {}),
1429
+ base_url: request_url
1430
+ }
1431
+ promise = @client.make_request_async(:get, path_template, options)
1432
+
1433
+ promise = promise.then do |result|
1434
+ http_response = result.response
1435
+ status_code = http_response.status
1436
+ response_content = http_response.body
1437
+ unless status_code == 200
1438
+ error_model = JSON.load(response_content)
1439
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
1440
+ end
1441
+
1442
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1443
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
1444
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
1445
+ # Deserialize Response
1446
+ if status_code == 200
1447
+ begin
1448
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1449
+ result_mapper = Azure::Policy::Mgmt::V2019_09_01::Models::PolicyAssignmentListResult.mapper()
1450
+ result.body = @client.deserialize(result_mapper, parsed_response)
1451
+ rescue Exception => e
1452
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1453
+ end
1454
+ end
1455
+
1456
+ result
1457
+ end
1458
+
1459
+ promise.execute
1460
+ end
1461
+
1462
+ #
1463
+ # Retrieves all policy assignments that apply to a resource.
1464
+ #
1465
+ # This operation retrieves the list of all policy assignments associated with
1466
+ # the specified resource in the given resource group and subscription that
1467
+ # match the optional given $filter. Valid values for $filter are: 'atScope()'
1468
+ # or 'policyDefinitionId eq '{value}''. If $filter is not provided, the
1469
+ # unfiltered list includes all policy assignments associated with the resource,
1470
+ # including those that apply directly or from all containing scopes, as well as
1471
+ # any applied to resources contained within the resource. If $filter=atScope()
1472
+ # is provided, the returned list includes all policy assignments that apply to
1473
+ # the resource, which is everything in the unfiltered list except those applied
1474
+ # to resources contained within the resource. If $filter=policyDefinitionId eq
1475
+ # '{value}' is provided, the returned list includes all policy assignments of
1476
+ # the policy definition whose id is {value} that apply to the resource. Three
1477
+ # parameters plus the resource name are used to identify a specific resource.
1478
+ # If the resource is not part of a parent resource (the more common case), the
1479
+ # parent resource path should not be provided (or provided as ''). For example
1480
+ # a web app could be specified as ({resourceProviderNamespace} ==
1481
+ # 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites',
1482
+ # {resourceName} == 'MyWebApp'). If the resource is part of a parent resource,
1483
+ # then all parameters should be provided. For example a virtual machine DNS
1484
+ # name could be specified as ({resourceProviderNamespace} ==
1485
+ # 'Microsoft.Compute', {parentResourcePath} ==
1486
+ # 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames',
1487
+ # {resourceName} == 'MyComputerName'). A convenient alternative to providing
1488
+ # the namespace and type name separately is to provide both in the
1489
+ # {resourceType} parameter, format: ({resourceProviderNamespace} == '',
1490
+ # {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites',
1491
+ # {resourceName} == 'MyWebApp').
1492
+ #
1493
+ # @param next_page_link [String] The NextLink from the previous successful call
1494
+ # to List operation.
1495
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1496
+ # will be added to the HTTP request.
1497
+ #
1498
+ # @return [PolicyAssignmentListResult] operation results.
1499
+ #
1500
+ def list_for_resource_next(next_page_link, custom_headers:nil)
1501
+ response = list_for_resource_next_async(next_page_link, custom_headers:custom_headers).value!
1502
+ response.body unless response.nil?
1503
+ end
1504
+
1505
+ #
1506
+ # Retrieves all policy assignments that apply to a resource.
1507
+ #
1508
+ # This operation retrieves the list of all policy assignments associated with
1509
+ # the specified resource in the given resource group and subscription that
1510
+ # match the optional given $filter. Valid values for $filter are: 'atScope()'
1511
+ # or 'policyDefinitionId eq '{value}''. If $filter is not provided, the
1512
+ # unfiltered list includes all policy assignments associated with the resource,
1513
+ # including those that apply directly or from all containing scopes, as well as
1514
+ # any applied to resources contained within the resource. If $filter=atScope()
1515
+ # is provided, the returned list includes all policy assignments that apply to
1516
+ # the resource, which is everything in the unfiltered list except those applied
1517
+ # to resources contained within the resource. If $filter=policyDefinitionId eq
1518
+ # '{value}' is provided, the returned list includes all policy assignments of
1519
+ # the policy definition whose id is {value} that apply to the resource. Three
1520
+ # parameters plus the resource name are used to identify a specific resource.
1521
+ # If the resource is not part of a parent resource (the more common case), the
1522
+ # parent resource path should not be provided (or provided as ''). For example
1523
+ # a web app could be specified as ({resourceProviderNamespace} ==
1524
+ # 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites',
1525
+ # {resourceName} == 'MyWebApp'). If the resource is part of a parent resource,
1526
+ # then all parameters should be provided. For example a virtual machine DNS
1527
+ # name could be specified as ({resourceProviderNamespace} ==
1528
+ # 'Microsoft.Compute', {parentResourcePath} ==
1529
+ # 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames',
1530
+ # {resourceName} == 'MyComputerName'). A convenient alternative to providing
1531
+ # the namespace and type name separately is to provide both in the
1532
+ # {resourceType} parameter, format: ({resourceProviderNamespace} == '',
1533
+ # {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites',
1534
+ # {resourceName} == 'MyWebApp').
1535
+ #
1536
+ # @param next_page_link [String] The NextLink from the previous successful call
1537
+ # to List operation.
1538
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1539
+ # will be added to the HTTP request.
1540
+ #
1541
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1542
+ #
1543
+ def list_for_resource_next_with_http_info(next_page_link, custom_headers:nil)
1544
+ list_for_resource_next_async(next_page_link, custom_headers:custom_headers).value!
1545
+ end
1546
+
1547
+ #
1548
+ # Retrieves all policy assignments that apply to a resource.
1549
+ #
1550
+ # This operation retrieves the list of all policy assignments associated with
1551
+ # the specified resource in the given resource group and subscription that
1552
+ # match the optional given $filter. Valid values for $filter are: 'atScope()'
1553
+ # or 'policyDefinitionId eq '{value}''. If $filter is not provided, the
1554
+ # unfiltered list includes all policy assignments associated with the resource,
1555
+ # including those that apply directly or from all containing scopes, as well as
1556
+ # any applied to resources contained within the resource. If $filter=atScope()
1557
+ # is provided, the returned list includes all policy assignments that apply to
1558
+ # the resource, which is everything in the unfiltered list except those applied
1559
+ # to resources contained within the resource. If $filter=policyDefinitionId eq
1560
+ # '{value}' is provided, the returned list includes all policy assignments of
1561
+ # the policy definition whose id is {value} that apply to the resource. Three
1562
+ # parameters plus the resource name are used to identify a specific resource.
1563
+ # If the resource is not part of a parent resource (the more common case), the
1564
+ # parent resource path should not be provided (or provided as ''). For example
1565
+ # a web app could be specified as ({resourceProviderNamespace} ==
1566
+ # 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites',
1567
+ # {resourceName} == 'MyWebApp'). If the resource is part of a parent resource,
1568
+ # then all parameters should be provided. For example a virtual machine DNS
1569
+ # name could be specified as ({resourceProviderNamespace} ==
1570
+ # 'Microsoft.Compute', {parentResourcePath} ==
1571
+ # 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames',
1572
+ # {resourceName} == 'MyComputerName'). A convenient alternative to providing
1573
+ # the namespace and type name separately is to provide both in the
1574
+ # {resourceType} parameter, format: ({resourceProviderNamespace} == '',
1575
+ # {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites',
1576
+ # {resourceName} == 'MyWebApp').
1577
+ #
1578
+ # @param next_page_link [String] The NextLink from the previous successful call
1579
+ # to List operation.
1580
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1581
+ # to the HTTP request.
1582
+ #
1583
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1584
+ #
1585
+ def list_for_resource_next_async(next_page_link, custom_headers:nil)
1586
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
1587
+
1588
+
1589
+ request_headers = {}
1590
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1591
+
1592
+ # Set Headers
1593
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1594
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1595
+ path_template = '{nextLink}'
1596
+
1597
+ request_url = @base_url || @client.base_url
1598
+
1599
+ options = {
1600
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1601
+ skip_encoding_path_params: {'nextLink' => next_page_link},
1602
+ headers: request_headers.merge(custom_headers || {}),
1603
+ base_url: request_url
1604
+ }
1605
+ promise = @client.make_request_async(:get, path_template, options)
1606
+
1607
+ promise = promise.then do |result|
1608
+ http_response = result.response
1609
+ status_code = http_response.status
1610
+ response_content = http_response.body
1611
+ unless status_code == 200
1612
+ error_model = JSON.load(response_content)
1613
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
1614
+ end
1615
+
1616
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1617
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
1618
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
1619
+ # Deserialize Response
1620
+ if status_code == 200
1621
+ begin
1622
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1623
+ result_mapper = Azure::Policy::Mgmt::V2019_09_01::Models::PolicyAssignmentListResult.mapper()
1624
+ result.body = @client.deserialize(result_mapper, parsed_response)
1625
+ rescue Exception => e
1626
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1627
+ end
1628
+ end
1629
+
1630
+ result
1631
+ end
1632
+
1633
+ promise.execute
1634
+ end
1635
+
1636
+ #
1637
+ # Retrieves all policy assignments that apply to a subscription.
1638
+ #
1639
+ # This operation retrieves the list of all policy assignments associated with
1640
+ # the given subscription that match the optional given $filter. Valid values
1641
+ # for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter
1642
+ # is not provided, the unfiltered list includes all policy assignments
1643
+ # associated with the subscription, including those that apply directly or from
1644
+ # management groups that contain the given subscription, as well as any applied
1645
+ # to objects contained within the subscription. If $filter=atScope() is
1646
+ # provided, the returned list includes all policy assignments that apply to the
1647
+ # subscription, which is everything in the unfiltered list except those applied
1648
+ # to objects contained within the subscription. If $filter=policyDefinitionId
1649
+ # eq '{value}' is provided, the returned list includes all policy assignments
1650
+ # of the policy definition whose id is {value}.
1651
+ #
1652
+ # @param next_page_link [String] The NextLink from the previous successful call
1653
+ # to List operation.
1654
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1655
+ # will be added to the HTTP request.
1656
+ #
1657
+ # @return [PolicyAssignmentListResult] operation results.
1658
+ #
1659
+ def list_next(next_page_link, custom_headers:nil)
1660
+ response = list_next_async(next_page_link, custom_headers:custom_headers).value!
1661
+ response.body unless response.nil?
1662
+ end
1663
+
1664
+ #
1665
+ # Retrieves all policy assignments that apply to a subscription.
1666
+ #
1667
+ # This operation retrieves the list of all policy assignments associated with
1668
+ # the given subscription that match the optional given $filter. Valid values
1669
+ # for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter
1670
+ # is not provided, the unfiltered list includes all policy assignments
1671
+ # associated with the subscription, including those that apply directly or from
1672
+ # management groups that contain the given subscription, as well as any applied
1673
+ # to objects contained within the subscription. If $filter=atScope() is
1674
+ # provided, the returned list includes all policy assignments that apply to the
1675
+ # subscription, which is everything in the unfiltered list except those applied
1676
+ # to objects contained within the subscription. If $filter=policyDefinitionId
1677
+ # eq '{value}' is provided, the returned list includes all policy assignments
1678
+ # of the policy definition whose id is {value}.
1679
+ #
1680
+ # @param next_page_link [String] The NextLink from the previous successful call
1681
+ # to List operation.
1682
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1683
+ # will be added to the HTTP request.
1684
+ #
1685
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1686
+ #
1687
+ def list_next_with_http_info(next_page_link, custom_headers:nil)
1688
+ list_next_async(next_page_link, custom_headers:custom_headers).value!
1689
+ end
1690
+
1691
+ #
1692
+ # Retrieves all policy assignments that apply to a subscription.
1693
+ #
1694
+ # This operation retrieves the list of all policy assignments associated with
1695
+ # the given subscription that match the optional given $filter. Valid values
1696
+ # for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter
1697
+ # is not provided, the unfiltered list includes all policy assignments
1698
+ # associated with the subscription, including those that apply directly or from
1699
+ # management groups that contain the given subscription, as well as any applied
1700
+ # to objects contained within the subscription. If $filter=atScope() is
1701
+ # provided, the returned list includes all policy assignments that apply to the
1702
+ # subscription, which is everything in the unfiltered list except those applied
1703
+ # to objects contained within the subscription. If $filter=policyDefinitionId
1704
+ # eq '{value}' is provided, the returned list includes all policy assignments
1705
+ # of the policy definition whose id is {value}.
1706
+ #
1707
+ # @param next_page_link [String] The NextLink from the previous successful call
1708
+ # to List operation.
1709
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1710
+ # to the HTTP request.
1711
+ #
1712
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1713
+ #
1714
+ def list_next_async(next_page_link, custom_headers:nil)
1715
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
1716
+
1717
+
1718
+ request_headers = {}
1719
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1720
+
1721
+ # Set Headers
1722
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1723
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1724
+ path_template = '{nextLink}'
1725
+
1726
+ request_url = @base_url || @client.base_url
1727
+
1728
+ options = {
1729
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1730
+ skip_encoding_path_params: {'nextLink' => next_page_link},
1731
+ headers: request_headers.merge(custom_headers || {}),
1732
+ base_url: request_url
1733
+ }
1734
+ promise = @client.make_request_async(:get, path_template, options)
1735
+
1736
+ promise = promise.then do |result|
1737
+ http_response = result.response
1738
+ status_code = http_response.status
1739
+ response_content = http_response.body
1740
+ unless status_code == 200
1741
+ error_model = JSON.load(response_content)
1742
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
1743
+ end
1744
+
1745
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1746
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
1747
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
1748
+ # Deserialize Response
1749
+ if status_code == 200
1750
+ begin
1751
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1752
+ result_mapper = Azure::Policy::Mgmt::V2019_09_01::Models::PolicyAssignmentListResult.mapper()
1753
+ result.body = @client.deserialize(result_mapper, parsed_response)
1754
+ rescue Exception => e
1755
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1756
+ end
1757
+ end
1758
+
1759
+ result
1760
+ end
1761
+
1762
+ promise.execute
1763
+ end
1764
+
1765
+ #
1766
+ # Retrieves all policy assignments that apply to a resource group.
1767
+ #
1768
+ # This operation retrieves the list of all policy assignments associated with
1769
+ # the given resource group in the given subscription that match the optional
1770
+ # given $filter. Valid values for $filter are: 'atScope()' or
1771
+ # 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered
1772
+ # list includes all policy assignments associated with the resource group,
1773
+ # including those that apply directly or apply from containing scopes, as well
1774
+ # as any applied to resources contained within the resource group. If
1775
+ # $filter=atScope() is provided, the returned list includes all policy
1776
+ # assignments that apply to the resource group, which is everything in the
1777
+ # unfiltered list except those applied to resources contained within the
1778
+ # resource group. If $filter=policyDefinitionId eq '{value}' is provided, the
1779
+ # returned list includes all policy assignments of the policy definition whose
1780
+ # id is {value} that apply to the resource group.
1781
+ #
1782
+ # @param resource_group_name [String] The name of the resource group that
1783
+ # contains policy assignments.
1784
+ # @param filter [String] The filter to apply on the operation. Valid values for
1785
+ # $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is
1786
+ # not provided, no filtering is performed.
1787
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1788
+ # will be added to the HTTP request.
1789
+ #
1790
+ # @return [PolicyAssignmentListResult] which provide lazy access to pages of
1791
+ # the response.
1792
+ #
1793
+ def list_for_resource_group_as_lazy(resource_group_name, filter:nil, custom_headers:nil)
1794
+ response = list_for_resource_group_async(resource_group_name, filter:filter, custom_headers:custom_headers).value!
1795
+ unless response.nil?
1796
+ page = response.body
1797
+ page.next_method = Proc.new do |next_page_link|
1798
+ list_for_resource_group_next_async(next_page_link, custom_headers:custom_headers)
1799
+ end
1800
+ page
1801
+ end
1802
+ end
1803
+
1804
+ #
1805
+ # Retrieves all policy assignments that apply to a resource.
1806
+ #
1807
+ # This operation retrieves the list of all policy assignments associated with
1808
+ # the specified resource in the given resource group and subscription that
1809
+ # match the optional given $filter. Valid values for $filter are: 'atScope()'
1810
+ # or 'policyDefinitionId eq '{value}''. If $filter is not provided, the
1811
+ # unfiltered list includes all policy assignments associated with the resource,
1812
+ # including those that apply directly or from all containing scopes, as well as
1813
+ # any applied to resources contained within the resource. If $filter=atScope()
1814
+ # is provided, the returned list includes all policy assignments that apply to
1815
+ # the resource, which is everything in the unfiltered list except those applied
1816
+ # to resources contained within the resource. If $filter=policyDefinitionId eq
1817
+ # '{value}' is provided, the returned list includes all policy assignments of
1818
+ # the policy definition whose id is {value} that apply to the resource. Three
1819
+ # parameters plus the resource name are used to identify a specific resource.
1820
+ # If the resource is not part of a parent resource (the more common case), the
1821
+ # parent resource path should not be provided (or provided as ''). For example
1822
+ # a web app could be specified as ({resourceProviderNamespace} ==
1823
+ # 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites',
1824
+ # {resourceName} == 'MyWebApp'). If the resource is part of a parent resource,
1825
+ # then all parameters should be provided. For example a virtual machine DNS
1826
+ # name could be specified as ({resourceProviderNamespace} ==
1827
+ # 'Microsoft.Compute', {parentResourcePath} ==
1828
+ # 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames',
1829
+ # {resourceName} == 'MyComputerName'). A convenient alternative to providing
1830
+ # the namespace and type name separately is to provide both in the
1831
+ # {resourceType} parameter, format: ({resourceProviderNamespace} == '',
1832
+ # {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites',
1833
+ # {resourceName} == 'MyWebApp').
1834
+ #
1835
+ # @param resource_group_name [String] The name of the resource group containing
1836
+ # the resource.
1837
+ # @param resource_provider_namespace [String] The namespace of the resource
1838
+ # provider. For example, the namespace of a virtual machine is
1839
+ # Microsoft.Compute (from Microsoft.Compute/virtualMachines)
1840
+ # @param parent_resource_path [String] The parent resource path. Use empty
1841
+ # string if there is none.
1842
+ # @param resource_type [String] The resource type name. For example the type
1843
+ # name of a web app is 'sites' (from Microsoft.Web/sites).
1844
+ # @param resource_name [String] The name of the resource.
1845
+ # @param filter [String] The filter to apply on the operation. Valid values for
1846
+ # $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is
1847
+ # not provided, no filtering is performed.
1848
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1849
+ # will be added to the HTTP request.
1850
+ #
1851
+ # @return [PolicyAssignmentListResult] which provide lazy access to pages of
1852
+ # the response.
1853
+ #
1854
+ def list_for_resource_as_lazy(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter:nil, custom_headers:nil)
1855
+ response = list_for_resource_async(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter:filter, custom_headers:custom_headers).value!
1856
+ unless response.nil?
1857
+ page = response.body
1858
+ page.next_method = Proc.new do |next_page_link|
1859
+ list_for_resource_next_async(next_page_link, custom_headers:custom_headers)
1860
+ end
1861
+ page
1862
+ end
1863
+ end
1864
+
1865
+ #
1866
+ # Retrieves all policy assignments that apply to a subscription.
1867
+ #
1868
+ # This operation retrieves the list of all policy assignments associated with
1869
+ # the given subscription that match the optional given $filter. Valid values
1870
+ # for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter
1871
+ # is not provided, the unfiltered list includes all policy assignments
1872
+ # associated with the subscription, including those that apply directly or from
1873
+ # management groups that contain the given subscription, as well as any applied
1874
+ # to objects contained within the subscription. If $filter=atScope() is
1875
+ # provided, the returned list includes all policy assignments that apply to the
1876
+ # subscription, which is everything in the unfiltered list except those applied
1877
+ # to objects contained within the subscription. If $filter=policyDefinitionId
1878
+ # eq '{value}' is provided, the returned list includes all policy assignments
1879
+ # of the policy definition whose id is {value}.
1880
+ #
1881
+ # @param filter [String] The filter to apply on the operation. Valid values for
1882
+ # $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is
1883
+ # not provided, no filtering is performed.
1884
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1885
+ # will be added to the HTTP request.
1886
+ #
1887
+ # @return [PolicyAssignmentListResult] which provide lazy access to pages of
1888
+ # the response.
1889
+ #
1890
+ def list_as_lazy(filter:nil, custom_headers:nil)
1891
+ response = list_async(filter:filter, custom_headers:custom_headers).value!
1892
+ unless response.nil?
1893
+ page = response.body
1894
+ page.next_method = Proc.new do |next_page_link|
1895
+ list_next_async(next_page_link, custom_headers:custom_headers)
1896
+ end
1897
+ page
1898
+ end
1899
+ end
1900
+
1901
+ end
1902
+ end