1# coding=utf-8 2# -------------------------------------------------------------------------- 3# Copyright (c) Microsoft Corporation. All rights reserved. 4# Licensed under the MIT License. See License.txt in the project root for 5# license information. 6# 7# Code generated by Microsoft (R) AutoRest Code Generator. 8# Changes may cause incorrect behavior and will be lost if the code is 9# regenerated. 10# -------------------------------------------------------------------------- 11 12import uuid 13from msrest.pipeline import ClientRawResponse 14 15from .. import models 16 17 18class GroupsOperations(object): 19 """GroupsOperations operations. 20 21 :param client: Client for service requests. 22 :param config: Configuration of service client. 23 :param serializer: An object model serializer. 24 :param deserializer: An object model deserializer. 25 :ivar api_version: Client API version. Constant value: "1.6". 26 """ 27 28 models = models 29 30 def __init__(self, client, config, serializer, deserializer): 31 32 self._client = client 33 self._serialize = serializer 34 self._deserialize = deserializer 35 self.api_version = "1.6" 36 37 self.config = config 38 39 def is_member_of( 40 self, parameters, custom_headers=None, raw=False, **operation_config): 41 """Checks whether the specified user, group, contact, or service principal 42 is a direct or transitive member of the specified group. 43 44 :param parameters: The check group membership parameters. 45 :type parameters: 46 ~azure.graphrbac.models.CheckGroupMembershipParameters 47 :param dict custom_headers: headers that will be added to the request 48 :param bool raw: returns the direct response alongside the 49 deserialized response 50 :param operation_config: :ref:`Operation configuration 51 overrides<msrest:optionsforoperations>`. 52 :return: CheckGroupMembershipResult or ClientRawResponse if raw=true 53 :rtype: ~azure.graphrbac.models.CheckGroupMembershipResult or 54 ~msrest.pipeline.ClientRawResponse 55 :raises: 56 :class:`GraphErrorException<azure.graphrbac.models.GraphErrorException>` 57 """ 58 # Construct URL 59 url = self.is_member_of.metadata['url'] 60 path_format_arguments = { 61 'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str') 62 } 63 url = self._client.format_url(url, **path_format_arguments) 64 65 # Construct parameters 66 query_parameters = {} 67 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 68 69 # Construct headers 70 header_parameters = {} 71 header_parameters['Accept'] = 'application/json' 72 header_parameters['Content-Type'] = 'application/json; charset=utf-8' 73 if self.config.generate_client_request_id: 74 header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) 75 if custom_headers: 76 header_parameters.update(custom_headers) 77 if self.config.accept_language is not None: 78 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 79 80 # Construct body 81 body_content = self._serialize.body(parameters, 'CheckGroupMembershipParameters') 82 83 # Construct and send request 84 request = self._client.post(url, query_parameters, header_parameters, body_content) 85 response = self._client.send(request, stream=False, **operation_config) 86 87 if response.status_code not in [200]: 88 raise models.GraphErrorException(self._deserialize, response) 89 90 deserialized = None 91 92 if response.status_code == 200: 93 deserialized = self._deserialize('CheckGroupMembershipResult', response) 94 95 if raw: 96 client_raw_response = ClientRawResponse(deserialized, response) 97 return client_raw_response 98 99 return deserialized 100 is_member_of.metadata = {'url': '/{tenantID}/isMemberOf'} 101 102 def remove_member( 103 self, group_object_id, member_object_id, custom_headers=None, raw=False, **operation_config): 104 """Remove a member from a group. 105 106 :param group_object_id: The object ID of the group from which to 107 remove the member. 108 :type group_object_id: str 109 :param member_object_id: Member object id 110 :type member_object_id: str 111 :param dict custom_headers: headers that will be added to the request 112 :param bool raw: returns the direct response alongside the 113 deserialized response 114 :param operation_config: :ref:`Operation configuration 115 overrides<msrest:optionsforoperations>`. 116 :return: None or ClientRawResponse if raw=true 117 :rtype: None or ~msrest.pipeline.ClientRawResponse 118 :raises: 119 :class:`GraphErrorException<azure.graphrbac.models.GraphErrorException>` 120 """ 121 # Construct URL 122 url = self.remove_member.metadata['url'] 123 path_format_arguments = { 124 'groupObjectId': self._serialize.url("group_object_id", group_object_id, 'str'), 125 'memberObjectId': self._serialize.url("member_object_id", member_object_id, 'str'), 126 'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str') 127 } 128 url = self._client.format_url(url, **path_format_arguments) 129 130 # Construct parameters 131 query_parameters = {} 132 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 133 134 # Construct headers 135 header_parameters = {} 136 if self.config.generate_client_request_id: 137 header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) 138 if custom_headers: 139 header_parameters.update(custom_headers) 140 if self.config.accept_language is not None: 141 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 142 143 # Construct and send request 144 request = self._client.delete(url, query_parameters, header_parameters) 145 response = self._client.send(request, stream=False, **operation_config) 146 147 if response.status_code not in [204]: 148 raise models.GraphErrorException(self._deserialize, response) 149 150 if raw: 151 client_raw_response = ClientRawResponse(None, response) 152 return client_raw_response 153 remove_member.metadata = {'url': '/{tenantID}/groups/{groupObjectId}/$links/members/{memberObjectId}'} 154 155 def add_member( 156 self, group_object_id, url, additional_properties=None, custom_headers=None, raw=False, **operation_config): 157 """Add a member to a group. 158 159 :param group_object_id: The object ID of the group to which to add the 160 member. 161 :type group_object_id: str 162 :param url: A member object URL, such as 163 "https://graph.windows.net/0b1f9851-1bf0-433f-aec3-cb9272f093dc/directoryObjects/f260bbc4-c254-447b-94cf-293b5ec434dd", 164 where "0b1f9851-1bf0-433f-aec3-cb9272f093dc" is the tenantId and 165 "f260bbc4-c254-447b-94cf-293b5ec434dd" is the objectId of the member 166 (user, application, servicePrincipal, group) to be added. 167 :type url: str 168 :param additional_properties: Unmatched properties from the message 169 are deserialized this collection 170 :type additional_properties: dict[str, object] 171 :param dict custom_headers: headers that will be added to the request 172 :param bool raw: returns the direct response alongside the 173 deserialized response 174 :param operation_config: :ref:`Operation configuration 175 overrides<msrest:optionsforoperations>`. 176 :return: None or ClientRawResponse if raw=true 177 :rtype: None or ~msrest.pipeline.ClientRawResponse 178 :raises: 179 :class:`GraphErrorException<azure.graphrbac.models.GraphErrorException>` 180 """ 181 parameters = models.GroupAddMemberParameters(additional_properties=additional_properties, url=url) 182 183 # Construct URL 184 url = self.add_member.metadata['url'] 185 path_format_arguments = { 186 'groupObjectId': self._serialize.url("group_object_id", group_object_id, 'str'), 187 'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str') 188 } 189 url = self._client.format_url(url, **path_format_arguments) 190 191 # Construct parameters 192 query_parameters = {} 193 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 194 195 # Construct headers 196 header_parameters = {} 197 header_parameters['Content-Type'] = 'application/json; charset=utf-8' 198 if self.config.generate_client_request_id: 199 header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) 200 if custom_headers: 201 header_parameters.update(custom_headers) 202 if self.config.accept_language is not None: 203 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 204 205 # Construct body 206 body_content = self._serialize.body(parameters, 'GroupAddMemberParameters') 207 208 # Construct and send request 209 request = self._client.post(url, query_parameters, header_parameters, body_content) 210 response = self._client.send(request, stream=False, **operation_config) 211 212 if response.status_code not in [204]: 213 raise models.GraphErrorException(self._deserialize, response) 214 215 if raw: 216 client_raw_response = ClientRawResponse(None, response) 217 return client_raw_response 218 add_member.metadata = {'url': '/{tenantID}/groups/{groupObjectId}/$links/members'} 219 220 def create( 221 self, parameters, custom_headers=None, raw=False, **operation_config): 222 """Create a group in the directory. 223 224 :param parameters: The parameters for the group to create. 225 :type parameters: ~azure.graphrbac.models.GroupCreateParameters 226 :param dict custom_headers: headers that will be added to the request 227 :param bool raw: returns the direct response alongside the 228 deserialized response 229 :param operation_config: :ref:`Operation configuration 230 overrides<msrest:optionsforoperations>`. 231 :return: ADGroup or ClientRawResponse if raw=true 232 :rtype: ~azure.graphrbac.models.ADGroup or 233 ~msrest.pipeline.ClientRawResponse 234 :raises: 235 :class:`GraphErrorException<azure.graphrbac.models.GraphErrorException>` 236 """ 237 # Construct URL 238 url = self.create.metadata['url'] 239 path_format_arguments = { 240 'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str') 241 } 242 url = self._client.format_url(url, **path_format_arguments) 243 244 # Construct parameters 245 query_parameters = {} 246 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 247 248 # Construct headers 249 header_parameters = {} 250 header_parameters['Accept'] = 'application/json' 251 header_parameters['Content-Type'] = 'application/json; charset=utf-8' 252 if self.config.generate_client_request_id: 253 header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) 254 if custom_headers: 255 header_parameters.update(custom_headers) 256 if self.config.accept_language is not None: 257 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 258 259 # Construct body 260 body_content = self._serialize.body(parameters, 'GroupCreateParameters') 261 262 # Construct and send request 263 request = self._client.post(url, query_parameters, header_parameters, body_content) 264 response = self._client.send(request, stream=False, **operation_config) 265 266 if response.status_code not in [201]: 267 raise models.GraphErrorException(self._deserialize, response) 268 269 deserialized = None 270 271 if response.status_code == 201: 272 deserialized = self._deserialize('ADGroup', response) 273 274 if raw: 275 client_raw_response = ClientRawResponse(deserialized, response) 276 return client_raw_response 277 278 return deserialized 279 create.metadata = {'url': '/{tenantID}/groups'} 280 281 def list( 282 self, filter=None, custom_headers=None, raw=False, **operation_config): 283 """Gets list of groups for the current tenant. 284 285 :param filter: The filter to apply to the operation. 286 :type filter: str 287 :param dict custom_headers: headers that will be added to the request 288 :param bool raw: returns the direct response alongside the 289 deserialized response 290 :param operation_config: :ref:`Operation configuration 291 overrides<msrest:optionsforoperations>`. 292 :return: An iterator like instance of ADGroup 293 :rtype: 294 ~azure.graphrbac.models.ADGroupPaged[~azure.graphrbac.models.ADGroup] 295 :raises: 296 :class:`GraphErrorException<azure.graphrbac.models.GraphErrorException>` 297 """ 298 def internal_paging(next_link=None, raw=False): 299 300 if not next_link: 301 # Construct URL 302 url = self.list.metadata['url'] 303 path_format_arguments = { 304 'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str') 305 } 306 url = self._client.format_url(url, **path_format_arguments) 307 308 # Construct parameters 309 query_parameters = {} 310 if filter is not None: 311 query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') 312 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 313 314 else: 315 url = '/{tenantID}/{nextLink}' 316 path_format_arguments = { 317 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), 318 'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str') 319 } 320 url = self._client.format_url(url, **path_format_arguments) 321 query_parameters = {} 322 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 323 324 # Construct headers 325 header_parameters = {} 326 header_parameters['Accept'] = 'application/json' 327 if self.config.generate_client_request_id: 328 header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) 329 if custom_headers: 330 header_parameters.update(custom_headers) 331 if self.config.accept_language is not None: 332 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 333 334 # Construct and send request 335 request = self._client.get(url, query_parameters, header_parameters) 336 response = self._client.send(request, stream=False, **operation_config) 337 338 if response.status_code not in [200]: 339 raise models.GraphErrorException(self._deserialize, response) 340 341 return response 342 343 # Deserialize response 344 deserialized = models.ADGroupPaged(internal_paging, self._deserialize.dependencies) 345 346 if raw: 347 header_dict = {} 348 client_raw_response = models.ADGroupPaged(internal_paging, self._deserialize.dependencies, header_dict) 349 return client_raw_response 350 351 return deserialized 352 list.metadata = {'url': '/{tenantID}/groups'} 353 354 def get_group_members( 355 self, object_id, custom_headers=None, raw=False, **operation_config): 356 """Gets the members of a group. 357 358 :param object_id: The object ID of the group whose members should be 359 retrieved. 360 :type object_id: str 361 :param dict custom_headers: headers that will be added to the request 362 :param bool raw: returns the direct response alongside the 363 deserialized response 364 :param operation_config: :ref:`Operation configuration 365 overrides<msrest:optionsforoperations>`. 366 :return: An iterator like instance of DirectoryObject 367 :rtype: 368 ~azure.graphrbac.models.DirectoryObjectPaged[~azure.graphrbac.models.DirectoryObject] 369 :raises: 370 :class:`GraphErrorException<azure.graphrbac.models.GraphErrorException>` 371 """ 372 def internal_paging(next_link=None, raw=False): 373 374 if not next_link: 375 # Construct URL 376 url = self.get_group_members.metadata['url'] 377 path_format_arguments = { 378 'objectId': self._serialize.url("object_id", object_id, 'str'), 379 'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str') 380 } 381 url = self._client.format_url(url, **path_format_arguments) 382 383 # Construct parameters 384 query_parameters = {} 385 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 386 387 else: 388 url = '/{tenantID}/{nextLink}' 389 path_format_arguments = { 390 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), 391 'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str') 392 } 393 url = self._client.format_url(url, **path_format_arguments) 394 query_parameters = {} 395 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 396 397 # Construct headers 398 header_parameters = {} 399 header_parameters['Accept'] = 'application/json' 400 if self.config.generate_client_request_id: 401 header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) 402 if custom_headers: 403 header_parameters.update(custom_headers) 404 if self.config.accept_language is not None: 405 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 406 407 # Construct and send request 408 request = self._client.get(url, query_parameters, header_parameters) 409 response = self._client.send(request, stream=False, **operation_config) 410 411 if response.status_code not in [200]: 412 raise models.GraphErrorException(self._deserialize, response) 413 414 return response 415 416 # Deserialize response 417 deserialized = models.DirectoryObjectPaged(internal_paging, self._deserialize.dependencies) 418 419 if raw: 420 header_dict = {} 421 client_raw_response = models.DirectoryObjectPaged(internal_paging, self._deserialize.dependencies, header_dict) 422 return client_raw_response 423 424 return deserialized 425 get_group_members.metadata = {'url': '/{tenantID}/groups/{objectId}/members'} 426 427 def get( 428 self, object_id, custom_headers=None, raw=False, **operation_config): 429 """Gets group information from the directory. 430 431 :param object_id: The object ID of the user for which to get group 432 information. 433 :type object_id: str 434 :param dict custom_headers: headers that will be added to the request 435 :param bool raw: returns the direct response alongside the 436 deserialized response 437 :param operation_config: :ref:`Operation configuration 438 overrides<msrest:optionsforoperations>`. 439 :return: ADGroup or ClientRawResponse if raw=true 440 :rtype: ~azure.graphrbac.models.ADGroup or 441 ~msrest.pipeline.ClientRawResponse 442 :raises: 443 :class:`GraphErrorException<azure.graphrbac.models.GraphErrorException>` 444 """ 445 # Construct URL 446 url = self.get.metadata['url'] 447 path_format_arguments = { 448 'objectId': self._serialize.url("object_id", object_id, 'str'), 449 'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str') 450 } 451 url = self._client.format_url(url, **path_format_arguments) 452 453 # Construct parameters 454 query_parameters = {} 455 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 456 457 # Construct headers 458 header_parameters = {} 459 header_parameters['Accept'] = 'application/json' 460 if self.config.generate_client_request_id: 461 header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) 462 if custom_headers: 463 header_parameters.update(custom_headers) 464 if self.config.accept_language is not None: 465 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 466 467 # Construct and send request 468 request = self._client.get(url, query_parameters, header_parameters) 469 response = self._client.send(request, stream=False, **operation_config) 470 471 if response.status_code not in [200]: 472 raise models.GraphErrorException(self._deserialize, response) 473 474 deserialized = None 475 476 if response.status_code == 200: 477 deserialized = self._deserialize('ADGroup', response) 478 479 if raw: 480 client_raw_response = ClientRawResponse(deserialized, response) 481 return client_raw_response 482 483 return deserialized 484 get.metadata = {'url': '/{tenantID}/groups/{objectId}'} 485 486 def delete( 487 self, object_id, custom_headers=None, raw=False, **operation_config): 488 """Delete a group from the directory. 489 490 :param object_id: The object ID of the group to delete. 491 :type object_id: str 492 :param dict custom_headers: headers that will be added to the request 493 :param bool raw: returns the direct response alongside the 494 deserialized response 495 :param operation_config: :ref:`Operation configuration 496 overrides<msrest:optionsforoperations>`. 497 :return: None or ClientRawResponse if raw=true 498 :rtype: None or ~msrest.pipeline.ClientRawResponse 499 :raises: 500 :class:`GraphErrorException<azure.graphrbac.models.GraphErrorException>` 501 """ 502 # Construct URL 503 url = self.delete.metadata['url'] 504 path_format_arguments = { 505 'objectId': self._serialize.url("object_id", object_id, 'str'), 506 'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str') 507 } 508 url = self._client.format_url(url, **path_format_arguments) 509 510 # Construct parameters 511 query_parameters = {} 512 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 513 514 # Construct headers 515 header_parameters = {} 516 if self.config.generate_client_request_id: 517 header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) 518 if custom_headers: 519 header_parameters.update(custom_headers) 520 if self.config.accept_language is not None: 521 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 522 523 # Construct and send request 524 request = self._client.delete(url, query_parameters, header_parameters) 525 response = self._client.send(request, stream=False, **operation_config) 526 527 if response.status_code not in [204]: 528 raise models.GraphErrorException(self._deserialize, response) 529 530 if raw: 531 client_raw_response = ClientRawResponse(None, response) 532 return client_raw_response 533 delete.metadata = {'url': '/{tenantID}/groups/{objectId}'} 534 535 def get_member_groups( 536 self, object_id, security_enabled_only, additional_properties=None, custom_headers=None, raw=False, **operation_config): 537 """Gets a collection of object IDs of groups of which the specified group 538 is a member. 539 540 :param object_id: The object ID of the group for which to get group 541 membership. 542 :type object_id: str 543 :param security_enabled_only: If true, only membership in 544 security-enabled groups should be checked. Otherwise, membership in 545 all groups should be checked. 546 :type security_enabled_only: bool 547 :param additional_properties: Unmatched properties from the message 548 are deserialized this collection 549 :type additional_properties: dict[str, object] 550 :param dict custom_headers: headers that will be added to the request 551 :param bool raw: returns the direct response alongside the 552 deserialized response 553 :param operation_config: :ref:`Operation configuration 554 overrides<msrest:optionsforoperations>`. 555 :return: An iterator like instance of str 556 :rtype: ~azure.graphrbac.models.StrPaged[str] 557 :raises: 558 :class:`GraphErrorException<azure.graphrbac.models.GraphErrorException>` 559 """ 560 parameters = models.GroupGetMemberGroupsParameters(additional_properties=additional_properties, security_enabled_only=security_enabled_only) 561 562 def internal_paging(next_link=None, raw=False): 563 564 if not next_link: 565 # Construct URL 566 url = self.get_member_groups.metadata['url'] 567 path_format_arguments = { 568 'objectId': self._serialize.url("object_id", object_id, 'str'), 569 'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str') 570 } 571 url = self._client.format_url(url, **path_format_arguments) 572 573 # Construct parameters 574 query_parameters = {} 575 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 576 577 else: 578 url = next_link 579 query_parameters = {} 580 581 # Construct headers 582 header_parameters = {} 583 header_parameters['Accept'] = 'application/json' 584 header_parameters['Content-Type'] = 'application/json; charset=utf-8' 585 if self.config.generate_client_request_id: 586 header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) 587 if custom_headers: 588 header_parameters.update(custom_headers) 589 if self.config.accept_language is not None: 590 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 591 592 # Construct body 593 body_content = self._serialize.body(parameters, 'GroupGetMemberGroupsParameters') 594 595 # Construct and send request 596 request = self._client.post(url, query_parameters, header_parameters, body_content) 597 response = self._client.send(request, stream=False, **operation_config) 598 599 if response.status_code not in [200]: 600 raise models.GraphErrorException(self._deserialize, response) 601 602 return response 603 604 # Deserialize response 605 deserialized = models.StrPaged(internal_paging, self._deserialize.dependencies) 606 607 if raw: 608 header_dict = {} 609 client_raw_response = models.StrPaged(internal_paging, self._deserialize.dependencies, header_dict) 610 return client_raw_response 611 612 return deserialized 613 get_member_groups.metadata = {'url': '/{tenantID}/groups/{objectId}/getMemberGroups'} 614 615 def list_owners( 616 self, object_id, custom_headers=None, raw=False, **operation_config): 617 """Directory objects that are owners of the group. 618 619 The owners are a set of non-admin users who are allowed to modify this 620 object. 621 622 :param object_id: The object ID of the group for which to get owners. 623 :type object_id: str 624 :param dict custom_headers: headers that will be added to the request 625 :param bool raw: returns the direct response alongside the 626 deserialized response 627 :param operation_config: :ref:`Operation configuration 628 overrides<msrest:optionsforoperations>`. 629 :return: An iterator like instance of DirectoryObject 630 :rtype: 631 ~azure.graphrbac.models.DirectoryObjectPaged[~azure.graphrbac.models.DirectoryObject] 632 :raises: 633 :class:`GraphErrorException<azure.graphrbac.models.GraphErrorException>` 634 """ 635 def internal_paging(next_link=None, raw=False): 636 637 if not next_link: 638 # Construct URL 639 url = self.list_owners.metadata['url'] 640 path_format_arguments = { 641 'objectId': self._serialize.url("object_id", object_id, 'str'), 642 'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str') 643 } 644 url = self._client.format_url(url, **path_format_arguments) 645 646 # Construct parameters 647 query_parameters = {} 648 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 649 650 else: 651 url = next_link 652 query_parameters = {} 653 654 # Construct headers 655 header_parameters = {} 656 header_parameters['Accept'] = 'application/json' 657 if self.config.generate_client_request_id: 658 header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) 659 if custom_headers: 660 header_parameters.update(custom_headers) 661 if self.config.accept_language is not None: 662 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 663 664 # Construct and send request 665 request = self._client.get(url, query_parameters, header_parameters) 666 response = self._client.send(request, stream=False, **operation_config) 667 668 if response.status_code not in [200]: 669 raise models.GraphErrorException(self._deserialize, response) 670 671 return response 672 673 # Deserialize response 674 deserialized = models.DirectoryObjectPaged(internal_paging, self._deserialize.dependencies) 675 676 if raw: 677 header_dict = {} 678 client_raw_response = models.DirectoryObjectPaged(internal_paging, self._deserialize.dependencies, header_dict) 679 return client_raw_response 680 681 return deserialized 682 list_owners.metadata = {'url': '/{tenantID}/groups/{objectId}/owners'} 683 684 def add_owner( 685 self, object_id, url, additional_properties=None, custom_headers=None, raw=False, **operation_config): 686 """Add an owner to a group. 687 688 :param object_id: The object ID of the application to which to add the 689 owner. 690 :type object_id: str 691 :param url: A owner object URL, such as 692 "https://graph.windows.net/0b1f9851-1bf0-433f-aec3-cb9272f093dc/directoryObjects/f260bbc4-c254-447b-94cf-293b5ec434dd", 693 where "0b1f9851-1bf0-433f-aec3-cb9272f093dc" is the tenantId and 694 "f260bbc4-c254-447b-94cf-293b5ec434dd" is the objectId of the owner 695 (user, application, servicePrincipal, group) to be added. 696 :type url: str 697 :param additional_properties: Unmatched properties from the message 698 are deserialized this collection 699 :type additional_properties: dict[str, object] 700 :param dict custom_headers: headers that will be added to the request 701 :param bool raw: returns the direct response alongside the 702 deserialized response 703 :param operation_config: :ref:`Operation configuration 704 overrides<msrest:optionsforoperations>`. 705 :return: None or ClientRawResponse if raw=true 706 :rtype: None or ~msrest.pipeline.ClientRawResponse 707 :raises: 708 :class:`GraphErrorException<azure.graphrbac.models.GraphErrorException>` 709 """ 710 parameters = models.AddOwnerParameters(additional_properties=additional_properties, url=url) 711 712 # Construct URL 713 url = self.add_owner.metadata['url'] 714 path_format_arguments = { 715 'objectId': self._serialize.url("object_id", object_id, 'str'), 716 'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str') 717 } 718 url = self._client.format_url(url, **path_format_arguments) 719 720 # Construct parameters 721 query_parameters = {} 722 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 723 724 # Construct headers 725 header_parameters = {} 726 header_parameters['Content-Type'] = 'application/json; charset=utf-8' 727 if self.config.generate_client_request_id: 728 header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) 729 if custom_headers: 730 header_parameters.update(custom_headers) 731 if self.config.accept_language is not None: 732 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 733 734 # Construct body 735 body_content = self._serialize.body(parameters, 'AddOwnerParameters') 736 737 # Construct and send request 738 request = self._client.post(url, query_parameters, header_parameters, body_content) 739 response = self._client.send(request, stream=False, **operation_config) 740 741 if response.status_code not in [204]: 742 raise models.GraphErrorException(self._deserialize, response) 743 744 if raw: 745 client_raw_response = ClientRawResponse(None, response) 746 return client_raw_response 747 add_owner.metadata = {'url': '/{tenantID}/groups/{objectId}/$links/owners'} 748 749 def remove_owner( 750 self, object_id, owner_object_id, custom_headers=None, raw=False, **operation_config): 751 """Remove a member from owners. 752 753 :param object_id: The object ID of the group from which to remove the 754 owner. 755 :type object_id: str 756 :param owner_object_id: Owner object id 757 :type owner_object_id: str 758 :param dict custom_headers: headers that will be added to the request 759 :param bool raw: returns the direct response alongside the 760 deserialized response 761 :param operation_config: :ref:`Operation configuration 762 overrides<msrest:optionsforoperations>`. 763 :return: None or ClientRawResponse if raw=true 764 :rtype: None or ~msrest.pipeline.ClientRawResponse 765 :raises: 766 :class:`GraphErrorException<azure.graphrbac.models.GraphErrorException>` 767 """ 768 # Construct URL 769 url = self.remove_owner.metadata['url'] 770 path_format_arguments = { 771 'objectId': self._serialize.url("object_id", object_id, 'str'), 772 'ownerObjectId': self._serialize.url("owner_object_id", owner_object_id, 'str'), 773 'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str') 774 } 775 url = self._client.format_url(url, **path_format_arguments) 776 777 # Construct parameters 778 query_parameters = {} 779 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 780 781 # Construct headers 782 header_parameters = {} 783 if self.config.generate_client_request_id: 784 header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) 785 if custom_headers: 786 header_parameters.update(custom_headers) 787 if self.config.accept_language is not None: 788 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 789 790 # Construct and send request 791 request = self._client.delete(url, query_parameters, header_parameters) 792 response = self._client.send(request, stream=False, **operation_config) 793 794 if response.status_code not in [204]: 795 raise models.GraphErrorException(self._deserialize, response) 796 797 if raw: 798 client_raw_response = ClientRawResponse(None, response) 799 return client_raw_response 800 remove_owner.metadata = {'url': '/{tenantID}/groups/{objectId}/$links/owners/{ownerObjectId}'} 801