azure_mgmt_graph 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/LICENSE.txt +21 -0
- data/Rakefile +5 -0
- data/azure_mgmt_graph.gemspec +35 -0
- data/lib/azure_mgmt_graph.rb +55 -0
- data/lib/azure_mgmt_graph/application_operations.rb +336 -0
- data/lib/azure_mgmt_graph/graph_rbac_management_client.rb +82 -0
- data/lib/azure_mgmt_graph/group_operations.rb +647 -0
- data/lib/azure_mgmt_graph/models/aadobject.rb +138 -0
- data/lib/azure_mgmt_graph/models/adgroup.rb +92 -0
- data/lib/azure_mgmt_graph/models/application.rb +122 -0
- data/lib/azure_mgmt_graph/models/application_create_parameters.rb +160 -0
- data/lib/azure_mgmt_graph/models/application_filter.rb +74 -0
- data/lib/azure_mgmt_graph/models/application_list_result.rb +76 -0
- data/lib/azure_mgmt_graph/models/get_objects_parameters.rb +77 -0
- data/lib/azure_mgmt_graph/models/get_objects_result.rb +85 -0
- data/lib/azure_mgmt_graph/models/group_add_member_parameters.rb +56 -0
- data/lib/azure_mgmt_graph/models/group_create_parameters.rb +86 -0
- data/lib/azure_mgmt_graph/models/group_get_member_groups_parameters.rb +58 -0
- data/lib/azure_mgmt_graph/models/group_get_member_groups_result.rb +56 -0
- data/lib/azure_mgmt_graph/models/group_list_result.rb +85 -0
- data/lib/azure_mgmt_graph/models/key_credential.rb +105 -0
- data/lib/azure_mgmt_graph/models/password_credential.rb +87 -0
- data/lib/azure_mgmt_graph/models/service_principal.rb +92 -0
- data/lib/azure_mgmt_graph/models/service_principal_create_parameters.rb +66 -0
- data/lib/azure_mgmt_graph/models/service_principal_list_result.rb +86 -0
- data/lib/azure_mgmt_graph/models/user.rb +101 -0
- data/lib/azure_mgmt_graph/models/user_create_parameters.rb +103 -0
- data/lib/azure_mgmt_graph/models/user_create_parameters_password_profile.rb +65 -0
- data/lib/azure_mgmt_graph/models/user_get_member_groups_parameters.rb +58 -0
- data/lib/azure_mgmt_graph/models/user_get_member_groups_result.rb +56 -0
- data/lib/azure_mgmt_graph/models/user_list_result.rb +85 -0
- data/lib/azure_mgmt_graph/module_definition.rb +8 -0
- data/lib/azure_mgmt_graph/object_operations.rb +217 -0
- data/lib/azure_mgmt_graph/service_principal_operations.rb +331 -0
- data/lib/azure_mgmt_graph/user_operations.rb +408 -0
- data/lib/azure_mgmt_graph/version.rb +8 -0
- metadata +166 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Code generated by Microsoft (R) AutoRest Code Generator 0.16.0.0
|
3
|
+
# Changes may cause incorrect behavior and will be lost if the code is
|
4
|
+
# regenerated.
|
5
|
+
|
6
|
+
module Azure::ARM::Graph
|
7
|
+
module Models
|
8
|
+
#
|
9
|
+
# Server response for GetMemberGroups API call
|
10
|
+
#
|
11
|
+
class UserGetMemberGroupsResult
|
12
|
+
|
13
|
+
include MsRestAzure
|
14
|
+
|
15
|
+
# @return [Array<String>] Group Ids of which the user is a member
|
16
|
+
attr_accessor :value
|
17
|
+
|
18
|
+
#
|
19
|
+
# Validate the object. Throws ValidationError if validation fails.
|
20
|
+
#
|
21
|
+
def validate
|
22
|
+
@value.each{ |e| e.validate if e.respond_to?(:validate) } unless @value.nil?
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
# Serializes given Model object into Ruby Hash.
|
27
|
+
# @param object Model object to serialize.
|
28
|
+
# @return [Hash] Serialized object in form of Ruby Hash.
|
29
|
+
#
|
30
|
+
def self.serialize_object(object)
|
31
|
+
object.validate
|
32
|
+
output_object = {}
|
33
|
+
|
34
|
+
serialized_property = object.value
|
35
|
+
output_object['value'] = serialized_property unless serialized_property.nil?
|
36
|
+
|
37
|
+
output_object
|
38
|
+
end
|
39
|
+
|
40
|
+
#
|
41
|
+
# Deserializes given Ruby Hash into Model object.
|
42
|
+
# @param object [Hash] Ruby Hash object to deserialize.
|
43
|
+
# @return [UserGetMemberGroupsResult] Deserialized object.
|
44
|
+
#
|
45
|
+
def self.deserialize_object(object)
|
46
|
+
return if object.nil?
|
47
|
+
output_object = UserGetMemberGroupsResult.new
|
48
|
+
|
49
|
+
deserialized_property = object['value']
|
50
|
+
output_object.value = deserialized_property
|
51
|
+
|
52
|
+
output_object
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Code generated by Microsoft (R) AutoRest Code Generator 0.16.0.0
|
3
|
+
# Changes may cause incorrect behavior and will be lost if the code is
|
4
|
+
# regenerated.
|
5
|
+
|
6
|
+
module Azure::ARM::Graph
|
7
|
+
module Models
|
8
|
+
#
|
9
|
+
# Server response for Get tenant users API call
|
10
|
+
#
|
11
|
+
class UserListResult
|
12
|
+
|
13
|
+
include MsRestAzure
|
14
|
+
|
15
|
+
# @return [Array<User>] Gets or sets the list of users.
|
16
|
+
attr_accessor :value
|
17
|
+
|
18
|
+
# @return [String] Gets or sets the URL to get the next set of results.
|
19
|
+
attr_accessor :odatanext_link
|
20
|
+
|
21
|
+
#
|
22
|
+
# Validate the object. Throws ValidationError if validation fails.
|
23
|
+
#
|
24
|
+
def validate
|
25
|
+
@value.each{ |e| e.validate if e.respond_to?(:validate) } unless @value.nil?
|
26
|
+
end
|
27
|
+
|
28
|
+
#
|
29
|
+
# Serializes given Model object into Ruby Hash.
|
30
|
+
# @param object Model object to serialize.
|
31
|
+
# @return [Hash] Serialized object in form of Ruby Hash.
|
32
|
+
#
|
33
|
+
def self.serialize_object(object)
|
34
|
+
object.validate
|
35
|
+
output_object = {}
|
36
|
+
|
37
|
+
serialized_property = object.value
|
38
|
+
unless serialized_property.nil?
|
39
|
+
serializedArray = []
|
40
|
+
serialized_property.each do |element|
|
41
|
+
unless element.nil?
|
42
|
+
element = User.serialize_object(element)
|
43
|
+
end
|
44
|
+
serializedArray.push(element)
|
45
|
+
end
|
46
|
+
serialized_property = serializedArray
|
47
|
+
end
|
48
|
+
output_object['value'] = serialized_property unless serialized_property.nil?
|
49
|
+
|
50
|
+
serialized_property = object.odatanext_link
|
51
|
+
output_object['odata.nextLink'] = serialized_property unless serialized_property.nil?
|
52
|
+
|
53
|
+
output_object
|
54
|
+
end
|
55
|
+
|
56
|
+
#
|
57
|
+
# Deserializes given Ruby Hash into Model object.
|
58
|
+
# @param object [Hash] Ruby Hash object to deserialize.
|
59
|
+
# @return [UserListResult] Deserialized object.
|
60
|
+
#
|
61
|
+
def self.deserialize_object(object)
|
62
|
+
return if object.nil?
|
63
|
+
output_object = UserListResult.new
|
64
|
+
|
65
|
+
deserialized_property = object['value']
|
66
|
+
unless deserialized_property.nil?
|
67
|
+
deserialized_array = []
|
68
|
+
deserialized_property.each do |element1|
|
69
|
+
unless element1.nil?
|
70
|
+
element1 = User.deserialize_object(element1)
|
71
|
+
end
|
72
|
+
deserialized_array.push(element1)
|
73
|
+
end
|
74
|
+
deserialized_property = deserialized_array
|
75
|
+
end
|
76
|
+
output_object.value = deserialized_property
|
77
|
+
|
78
|
+
deserialized_property = object['odata.nextLink']
|
79
|
+
output_object.odatanext_link = deserialized_property
|
80
|
+
|
81
|
+
output_object
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,217 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Code generated by Microsoft (R) AutoRest Code Generator 0.16.0.0
|
3
|
+
# Changes may cause incorrect behavior and will be lost if the code is
|
4
|
+
# regenerated.
|
5
|
+
|
6
|
+
module Azure::ARM::Graph
|
7
|
+
#
|
8
|
+
# ObjectOperations
|
9
|
+
#
|
10
|
+
class ObjectOperations
|
11
|
+
include Azure::ARM::Graph::Models
|
12
|
+
include MsRestAzure
|
13
|
+
|
14
|
+
#
|
15
|
+
# Creates and initializes a new instance of the ObjectOperations class.
|
16
|
+
# @param client service class for accessing basic functionality.
|
17
|
+
#
|
18
|
+
def initialize(client)
|
19
|
+
@client = client
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return reference to the GraphRbacManagementClient
|
23
|
+
attr_reader :client
|
24
|
+
|
25
|
+
#
|
26
|
+
# Gets the details for current logged in user
|
27
|
+
#
|
28
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
29
|
+
# applied to HTTP request.
|
30
|
+
#
|
31
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
32
|
+
# response.
|
33
|
+
#
|
34
|
+
def get_current_user(custom_headers = nil)
|
35
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
36
|
+
fail ArgumentError, '@client.tenant_id is nil' if @client.tenant_id.nil?
|
37
|
+
request_headers = {}
|
38
|
+
|
39
|
+
# Set Headers
|
40
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
41
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
42
|
+
path_template = '/{tenantID}/me'
|
43
|
+
options = {
|
44
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
45
|
+
path_params: {'tenantID' => @client.tenant_id},
|
46
|
+
query_params: {'api-version' => @client.api_version},
|
47
|
+
headers: request_headers.merge(custom_headers || {})
|
48
|
+
}
|
49
|
+
request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
|
50
|
+
promise = request.run_promise do |req|
|
51
|
+
@client.credentials.sign_request(req) unless @client.credentials.nil?
|
52
|
+
end
|
53
|
+
|
54
|
+
promise = promise.then do |http_response|
|
55
|
+
status_code = http_response.status
|
56
|
+
response_content = http_response.body
|
57
|
+
unless status_code == 200
|
58
|
+
error_model = JSON.load(response_content)
|
59
|
+
fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Create Result
|
63
|
+
result = MsRestAzure::AzureOperationResponse.new(request, http_response)
|
64
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
65
|
+
# Deserialize Response
|
66
|
+
if status_code == 200
|
67
|
+
begin
|
68
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
69
|
+
unless parsed_response.nil?
|
70
|
+
parsed_response = AADObject.deserialize_object(parsed_response)
|
71
|
+
end
|
72
|
+
result.body = parsed_response
|
73
|
+
rescue Exception => e
|
74
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
result
|
79
|
+
end
|
80
|
+
|
81
|
+
promise.execute
|
82
|
+
end
|
83
|
+
|
84
|
+
#
|
85
|
+
# Gets AD group membership by provided AD object Ids
|
86
|
+
#
|
87
|
+
# @param parameters [GetObjectsParameters] Objects filtering parameters.
|
88
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
89
|
+
# applied to HTTP request.
|
90
|
+
#
|
91
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
92
|
+
# response.
|
93
|
+
#
|
94
|
+
def get_objects_by_object_ids(parameters, custom_headers = nil)
|
95
|
+
fail ArgumentError, 'parameters is nil' if parameters.nil?
|
96
|
+
parameters.validate unless parameters.nil?
|
97
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
98
|
+
fail ArgumentError, '@client.tenant_id is nil' if @client.tenant_id.nil?
|
99
|
+
request_headers = {}
|
100
|
+
|
101
|
+
# Set Headers
|
102
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
103
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
104
|
+
|
105
|
+
# Serialize Request
|
106
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
107
|
+
unless parameters.nil?
|
108
|
+
parameters = GetObjectsParameters.serialize_object(parameters)
|
109
|
+
end
|
110
|
+
request_content = JSON.generate(parameters, quirks_mode: true)
|
111
|
+
path_template = '/{tenantID}/getObjectsByObjectIds'
|
112
|
+
options = {
|
113
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
114
|
+
path_params: {'tenantID' => @client.tenant_id},
|
115
|
+
query_params: {'api-version' => @client.api_version},
|
116
|
+
body: request_content,
|
117
|
+
headers: request_headers.merge(custom_headers || {})
|
118
|
+
}
|
119
|
+
request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :post, options)
|
120
|
+
promise = request.run_promise do |req|
|
121
|
+
@client.credentials.sign_request(req) unless @client.credentials.nil?
|
122
|
+
end
|
123
|
+
|
124
|
+
promise = promise.then do |http_response|
|
125
|
+
status_code = http_response.status
|
126
|
+
response_content = http_response.body
|
127
|
+
unless status_code == 200
|
128
|
+
error_model = JSON.load(response_content)
|
129
|
+
fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
|
130
|
+
end
|
131
|
+
|
132
|
+
# Create Result
|
133
|
+
result = MsRestAzure::AzureOperationResponse.new(request, http_response)
|
134
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
135
|
+
# Deserialize Response
|
136
|
+
if status_code == 200
|
137
|
+
begin
|
138
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
139
|
+
unless parsed_response.nil?
|
140
|
+
parsed_response = GetObjectsResult.deserialize_object(parsed_response)
|
141
|
+
end
|
142
|
+
result.body = parsed_response
|
143
|
+
rescue Exception => e
|
144
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
result
|
149
|
+
end
|
150
|
+
|
151
|
+
promise.execute
|
152
|
+
end
|
153
|
+
|
154
|
+
#
|
155
|
+
# Gets AD group membership by provided AD object Ids
|
156
|
+
#
|
157
|
+
# @param next_link [String] Next link for list operation.
|
158
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
159
|
+
# applied to HTTP request.
|
160
|
+
#
|
161
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
162
|
+
# response.
|
163
|
+
#
|
164
|
+
def get_objects_by_object_ids_next(next_link, custom_headers = nil)
|
165
|
+
fail ArgumentError, 'next_link is nil' if next_link.nil?
|
166
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
167
|
+
fail ArgumentError, '@client.tenant_id is nil' if @client.tenant_id.nil?
|
168
|
+
request_headers = {}
|
169
|
+
|
170
|
+
# Set Headers
|
171
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
172
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
173
|
+
path_template = '/{tenantID}/{nextLink}'
|
174
|
+
options = {
|
175
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
176
|
+
path_params: {'tenantID' => @client.tenant_id},
|
177
|
+
skip_encoding_path_params: {'nextLink' => next_link},
|
178
|
+
query_params: {'api-version' => @client.api_version},
|
179
|
+
headers: request_headers.merge(custom_headers || {})
|
180
|
+
}
|
181
|
+
request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :post, options)
|
182
|
+
promise = request.run_promise do |req|
|
183
|
+
@client.credentials.sign_request(req) unless @client.credentials.nil?
|
184
|
+
end
|
185
|
+
|
186
|
+
promise = promise.then do |http_response|
|
187
|
+
status_code = http_response.status
|
188
|
+
response_content = http_response.body
|
189
|
+
unless status_code == 200
|
190
|
+
error_model = JSON.load(response_content)
|
191
|
+
fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
|
192
|
+
end
|
193
|
+
|
194
|
+
# Create Result
|
195
|
+
result = MsRestAzure::AzureOperationResponse.new(request, http_response)
|
196
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
197
|
+
# Deserialize Response
|
198
|
+
if status_code == 200
|
199
|
+
begin
|
200
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
201
|
+
unless parsed_response.nil?
|
202
|
+
parsed_response = GetObjectsResult.deserialize_object(parsed_response)
|
203
|
+
end
|
204
|
+
result.body = parsed_response
|
205
|
+
rescue Exception => e
|
206
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
result
|
211
|
+
end
|
212
|
+
|
213
|
+
promise.execute
|
214
|
+
end
|
215
|
+
|
216
|
+
end
|
217
|
+
end
|
@@ -0,0 +1,331 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Code generated by Microsoft (R) AutoRest Code Generator 0.16.0.0
|
3
|
+
# Changes may cause incorrect behavior and will be lost if the code is
|
4
|
+
# regenerated.
|
5
|
+
|
6
|
+
module Azure::ARM::Graph
|
7
|
+
#
|
8
|
+
# ServicePrincipalOperations
|
9
|
+
#
|
10
|
+
class ServicePrincipalOperations
|
11
|
+
include Azure::ARM::Graph::Models
|
12
|
+
include MsRestAzure
|
13
|
+
|
14
|
+
#
|
15
|
+
# Creates and initializes a new instance of the ServicePrincipalOperations class.
|
16
|
+
# @param client service class for accessing basic functionality.
|
17
|
+
#
|
18
|
+
def initialize(client)
|
19
|
+
@client = client
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return reference to the GraphRbacManagementClient
|
23
|
+
attr_reader :client
|
24
|
+
|
25
|
+
#
|
26
|
+
# Creates a service principal in the directory.
|
27
|
+
#
|
28
|
+
# @param parameters [ServicePrincipalCreateParameters] Parameters to create a
|
29
|
+
# service principal.
|
30
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
31
|
+
# applied to HTTP request.
|
32
|
+
#
|
33
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
34
|
+
# response.
|
35
|
+
#
|
36
|
+
def create(parameters, custom_headers = nil)
|
37
|
+
fail ArgumentError, 'parameters is nil' if parameters.nil?
|
38
|
+
parameters.validate unless parameters.nil?
|
39
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
40
|
+
fail ArgumentError, '@client.tenant_id is nil' if @client.tenant_id.nil?
|
41
|
+
request_headers = {}
|
42
|
+
|
43
|
+
# Set Headers
|
44
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
45
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
46
|
+
|
47
|
+
# Serialize Request
|
48
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
49
|
+
unless parameters.nil?
|
50
|
+
parameters = ServicePrincipalCreateParameters.serialize_object(parameters)
|
51
|
+
end
|
52
|
+
request_content = JSON.generate(parameters, quirks_mode: true)
|
53
|
+
path_template = '/{tenantID}/servicePrincipals'
|
54
|
+
options = {
|
55
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
56
|
+
path_params: {'tenantID' => @client.tenant_id},
|
57
|
+
query_params: {'api-version' => @client.api_version},
|
58
|
+
body: request_content,
|
59
|
+
headers: request_headers.merge(custom_headers || {})
|
60
|
+
}
|
61
|
+
request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :post, options)
|
62
|
+
promise = request.run_promise do |req|
|
63
|
+
@client.credentials.sign_request(req) unless @client.credentials.nil?
|
64
|
+
end
|
65
|
+
|
66
|
+
promise = promise.then do |http_response|
|
67
|
+
status_code = http_response.status
|
68
|
+
response_content = http_response.body
|
69
|
+
unless status_code == 201
|
70
|
+
error_model = JSON.load(response_content)
|
71
|
+
fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
|
72
|
+
end
|
73
|
+
|
74
|
+
# Create Result
|
75
|
+
result = MsRestAzure::AzureOperationResponse.new(request, http_response)
|
76
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
77
|
+
# Deserialize Response
|
78
|
+
if status_code == 201
|
79
|
+
begin
|
80
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
81
|
+
unless parsed_response.nil?
|
82
|
+
parsed_response = ServicePrincipal.deserialize_object(parsed_response)
|
83
|
+
end
|
84
|
+
result.body = parsed_response
|
85
|
+
rescue Exception => e
|
86
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
result
|
91
|
+
end
|
92
|
+
|
93
|
+
promise.execute
|
94
|
+
end
|
95
|
+
|
96
|
+
#
|
97
|
+
# Gets list of service principals from the current tenant.
|
98
|
+
#
|
99
|
+
# @param filter [String] The filter to apply on the operation.
|
100
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
101
|
+
# applied to HTTP request.
|
102
|
+
#
|
103
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
104
|
+
# response.
|
105
|
+
#
|
106
|
+
def list(filter = nil, custom_headers = nil)
|
107
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
108
|
+
fail ArgumentError, '@client.tenant_id is nil' if @client.tenant_id.nil?
|
109
|
+
request_headers = {}
|
110
|
+
|
111
|
+
# Set Headers
|
112
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
113
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
114
|
+
path_template = '/{tenantID}/servicePrincipals'
|
115
|
+
options = {
|
116
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
117
|
+
path_params: {'tenantID' => @client.tenant_id},
|
118
|
+
query_params: {'$filter' => filter,'api-version' => @client.api_version},
|
119
|
+
headers: request_headers.merge(custom_headers || {})
|
120
|
+
}
|
121
|
+
request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
|
122
|
+
promise = request.run_promise do |req|
|
123
|
+
@client.credentials.sign_request(req) unless @client.credentials.nil?
|
124
|
+
end
|
125
|
+
|
126
|
+
promise = promise.then do |http_response|
|
127
|
+
status_code = http_response.status
|
128
|
+
response_content = http_response.body
|
129
|
+
unless status_code == 200
|
130
|
+
error_model = JSON.load(response_content)
|
131
|
+
fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
|
132
|
+
end
|
133
|
+
|
134
|
+
# Create Result
|
135
|
+
result = MsRestAzure::AzureOperationResponse.new(request, http_response)
|
136
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
137
|
+
# Deserialize Response
|
138
|
+
if status_code == 200
|
139
|
+
begin
|
140
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
141
|
+
unless parsed_response.nil?
|
142
|
+
parsed_response = ServicePrincipalListResult.deserialize_object(parsed_response)
|
143
|
+
end
|
144
|
+
result.body = parsed_response
|
145
|
+
rescue Exception => e
|
146
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
result
|
151
|
+
end
|
152
|
+
|
153
|
+
promise.execute
|
154
|
+
end
|
155
|
+
|
156
|
+
#
|
157
|
+
# Deletes service principal from the directory.
|
158
|
+
#
|
159
|
+
# @param object_id [String] Object id to delete service principal information.
|
160
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
161
|
+
# applied to HTTP request.
|
162
|
+
#
|
163
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
164
|
+
# response.
|
165
|
+
#
|
166
|
+
def delete(object_id, custom_headers = nil)
|
167
|
+
fail ArgumentError, 'object_id is nil' if object_id.nil?
|
168
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
169
|
+
fail ArgumentError, '@client.tenant_id is nil' if @client.tenant_id.nil?
|
170
|
+
request_headers = {}
|
171
|
+
|
172
|
+
# Set Headers
|
173
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
174
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
175
|
+
path_template = '/{tenantID}/servicePrincipals/{objectId}'
|
176
|
+
options = {
|
177
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
178
|
+
path_params: {'tenantID' => @client.tenant_id},
|
179
|
+
skip_encoding_path_params: {'objectId' => object_id},
|
180
|
+
query_params: {'api-version' => @client.api_version},
|
181
|
+
headers: request_headers.merge(custom_headers || {})
|
182
|
+
}
|
183
|
+
request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :delete, options)
|
184
|
+
promise = request.run_promise do |req|
|
185
|
+
@client.credentials.sign_request(req) unless @client.credentials.nil?
|
186
|
+
end
|
187
|
+
|
188
|
+
promise = promise.then do |http_response|
|
189
|
+
status_code = http_response.status
|
190
|
+
response_content = http_response.body
|
191
|
+
unless status_code == 204
|
192
|
+
error_model = JSON.load(response_content)
|
193
|
+
fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
|
194
|
+
end
|
195
|
+
|
196
|
+
# Create Result
|
197
|
+
result = MsRestAzure::AzureOperationResponse.new(request, http_response)
|
198
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
199
|
+
|
200
|
+
result
|
201
|
+
end
|
202
|
+
|
203
|
+
promise.execute
|
204
|
+
end
|
205
|
+
|
206
|
+
#
|
207
|
+
# Gets service principal information from the directory.
|
208
|
+
#
|
209
|
+
# @param object_id [String] Object id to get service principal information.
|
210
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
211
|
+
# applied to HTTP request.
|
212
|
+
#
|
213
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
214
|
+
# response.
|
215
|
+
#
|
216
|
+
def get(object_id, custom_headers = nil)
|
217
|
+
fail ArgumentError, 'object_id is nil' if object_id.nil?
|
218
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
219
|
+
fail ArgumentError, '@client.tenant_id is nil' if @client.tenant_id.nil?
|
220
|
+
request_headers = {}
|
221
|
+
|
222
|
+
# Set Headers
|
223
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
224
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
225
|
+
path_template = '/{tenantID}/servicePrincipals/{objectId}'
|
226
|
+
options = {
|
227
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
228
|
+
path_params: {'tenantID' => @client.tenant_id},
|
229
|
+
skip_encoding_path_params: {'objectId' => object_id},
|
230
|
+
query_params: {'api-version' => @client.api_version},
|
231
|
+
headers: request_headers.merge(custom_headers || {})
|
232
|
+
}
|
233
|
+
request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
|
234
|
+
promise = request.run_promise do |req|
|
235
|
+
@client.credentials.sign_request(req) unless @client.credentials.nil?
|
236
|
+
end
|
237
|
+
|
238
|
+
promise = promise.then do |http_response|
|
239
|
+
status_code = http_response.status
|
240
|
+
response_content = http_response.body
|
241
|
+
unless status_code == 200
|
242
|
+
error_model = JSON.load(response_content)
|
243
|
+
fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
|
244
|
+
end
|
245
|
+
|
246
|
+
# Create Result
|
247
|
+
result = MsRestAzure::AzureOperationResponse.new(request, http_response)
|
248
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
249
|
+
# Deserialize Response
|
250
|
+
if status_code == 200
|
251
|
+
begin
|
252
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
253
|
+
unless parsed_response.nil?
|
254
|
+
parsed_response = ServicePrincipal.deserialize_object(parsed_response)
|
255
|
+
end
|
256
|
+
result.body = parsed_response
|
257
|
+
rescue Exception => e
|
258
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
result
|
263
|
+
end
|
264
|
+
|
265
|
+
promise.execute
|
266
|
+
end
|
267
|
+
|
268
|
+
#
|
269
|
+
# Gets list of service principals from the current tenant.
|
270
|
+
#
|
271
|
+
# @param next_link [String] Next link for list operation.
|
272
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
273
|
+
# applied to HTTP request.
|
274
|
+
#
|
275
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
276
|
+
# response.
|
277
|
+
#
|
278
|
+
def list_next(next_link, custom_headers = nil)
|
279
|
+
fail ArgumentError, 'next_link is nil' if next_link.nil?
|
280
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
281
|
+
fail ArgumentError, '@client.tenant_id is nil' if @client.tenant_id.nil?
|
282
|
+
request_headers = {}
|
283
|
+
|
284
|
+
# Set Headers
|
285
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
286
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
287
|
+
path_template = '/{tenantID}/{nextLink}'
|
288
|
+
options = {
|
289
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
290
|
+
path_params: {'tenantID' => @client.tenant_id},
|
291
|
+
skip_encoding_path_params: {'nextLink' => next_link},
|
292
|
+
query_params: {'api-version' => @client.api_version},
|
293
|
+
headers: request_headers.merge(custom_headers || {})
|
294
|
+
}
|
295
|
+
request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
|
296
|
+
promise = request.run_promise do |req|
|
297
|
+
@client.credentials.sign_request(req) unless @client.credentials.nil?
|
298
|
+
end
|
299
|
+
|
300
|
+
promise = promise.then do |http_response|
|
301
|
+
status_code = http_response.status
|
302
|
+
response_content = http_response.body
|
303
|
+
unless status_code == 200
|
304
|
+
error_model = JSON.load(response_content)
|
305
|
+
fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
|
306
|
+
end
|
307
|
+
|
308
|
+
# Create Result
|
309
|
+
result = MsRestAzure::AzureOperationResponse.new(request, http_response)
|
310
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
311
|
+
# Deserialize Response
|
312
|
+
if status_code == 200
|
313
|
+
begin
|
314
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
315
|
+
unless parsed_response.nil?
|
316
|
+
parsed_response = ServicePrincipalListResult.deserialize_object(parsed_response)
|
317
|
+
end
|
318
|
+
result.body = parsed_response
|
319
|
+
rescue Exception => e
|
320
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
324
|
+
result
|
325
|
+
end
|
326
|
+
|
327
|
+
promise.execute
|
328
|
+
end
|
329
|
+
|
330
|
+
end
|
331
|
+
end
|