-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AutoPR graphrbac/data-plane] Added OAuth2 GET and POST to GraphRBAC.…
…json spec (#3063) * Generated from 7e6768db7f5cf3600aa596cf9c488c6b5ca34ca2 OAuth2 Permissions added to GraphRBAC stable * Generated from dfc2c5676d5c7be8c4ec55a4356e36cc677ee916 OAuth2Permissions and added Service Principal query by AppId * Generated from 6aa96687989842d043047ab3b93cd2e5e66b5dd5 OAuth2 Permissions added to GraphRBAC stable cleanup and validate * Generated from d2bcb30a79b50cc976ba2b049ff780f8ab8d8292 Permissions added to GraphRBAC model rename and linter issues addressed * Generated from 34825096e936c6c8ee69981113b58cd094f18e8f Add description to post body for OAuth2 Permissions
- Loading branch information
1 parent
de96a68
commit 6b97b62
Showing
6 changed files
with
233 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for | ||
# license information. | ||
# | ||
# Code generated by Microsoft (R) AutoRest Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is | ||
# regenerated. | ||
# -------------------------------------------------------------------------- | ||
|
||
from msrest.serialization import Model | ||
|
||
|
||
class Permissions(Model): | ||
"""Permissions. | ||
:param odatatype: Microsoft.DirectoryServices.OAuth2PermissionGrant | ||
:type odatatype: str | ||
:param client_id: The objectId of the Service Principal associated with | ||
the app | ||
:type client_id: str | ||
:param consent_type: Typically set to AllPrincipals | ||
:type consent_type: str | ||
:param principal_id: Set to null if AllPrincipals is set | ||
:type principal_id: object | ||
:param resource_id: Service Principal Id of the resource you want to grant | ||
:type resource_id: str | ||
:param scope: Typically set to user_impersonation | ||
:type scope: str | ||
:param start_time: Start time for TTL | ||
:type start_time: str | ||
:param expiry_time: Expiry time for TTL | ||
:type expiry_time: str | ||
""" | ||
|
||
_attribute_map = { | ||
'odatatype': {'key': 'odata\\.type', 'type': 'str'}, | ||
'client_id': {'key': 'clientId', 'type': 'str'}, | ||
'consent_type': {'key': 'consentType', 'type': 'str'}, | ||
'principal_id': {'key': 'principalId', 'type': 'object'}, | ||
'resource_id': {'key': 'resourceId', 'type': 'str'}, | ||
'scope': {'key': 'scope', 'type': 'str'}, | ||
'start_time': {'key': 'startTime', 'type': 'str'}, | ||
'expiry_time': {'key': 'expiryTime', 'type': 'str'}, | ||
} | ||
|
||
def __init__(self, odatatype=None, client_id=None, consent_type=None, principal_id=None, resource_id=None, scope=None, start_time=None, expiry_time=None): | ||
super(Permissions, self).__init__() | ||
self.odatatype = odatatype | ||
self.client_id = client_id | ||
self.consent_type = consent_type | ||
self.principal_id = principal_id | ||
self.resource_id = resource_id | ||
self.scope = scope | ||
self.start_time = start_time | ||
self.expiry_time = expiry_time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
165 changes: 165 additions & 0 deletions
165
azure-graphrbac/azure/graphrbac/operations/oauth2_operations.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for | ||
# license information. | ||
# | ||
# Code generated by Microsoft (R) AutoRest Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is | ||
# regenerated. | ||
# -------------------------------------------------------------------------- | ||
|
||
import uuid | ||
from msrest.pipeline import ClientRawResponse | ||
from msrestazure.azure_exceptions import CloudError | ||
|
||
from .. import models | ||
|
||
|
||
class OAuth2Operations(object): | ||
"""OAuth2Operations operations. | ||
:param client: Client for service requests. | ||
:param config: Configuration of service client. | ||
:param serializer: An object model serializer. | ||
:param deserializer: An object model deserializer. | ||
:ivar api_version: Client API version. Constant value: "1.6". | ||
""" | ||
|
||
models = models | ||
|
||
def __init__(self, client, config, serializer, deserializer): | ||
|
||
self._client = client | ||
self._serialize = serializer | ||
self._deserialize = deserializer | ||
self.api_version = "1.6" | ||
|
||
self.config = config | ||
|
||
def get( | ||
self, filter=None, custom_headers=None, raw=False, **operation_config): | ||
"""Queries OAuth2 permissions for the relevant SP ObjectId of an app. | ||
:param filter: This is the Service Principal ObjectId associated with | ||
the app | ||
:type filter: str | ||
:param dict custom_headers: headers that will be added to the request | ||
:param bool raw: returns the direct response alongside the | ||
deserialized response | ||
:param operation_config: :ref:`Operation configuration | ||
overrides<msrest:optionsforoperations>`. | ||
:return: Permissions or ClientRawResponse if raw=true | ||
:rtype: ~azure.graphrbac.models.Permissions or | ||
~msrest.pipeline.ClientRawResponse | ||
:raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` | ||
""" | ||
# Construct URL | ||
url = self.get.metadata['url'] | ||
path_format_arguments = { | ||
'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str') | ||
} | ||
url = self._client.format_url(url, **path_format_arguments) | ||
|
||
# Construct parameters | ||
query_parameters = {} | ||
if filter is not None: | ||
query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') | ||
query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') | ||
|
||
# Construct headers | ||
header_parameters = {} | ||
header_parameters['Content-Type'] = 'application/json; charset=utf-8' | ||
if self.config.generate_client_request_id: | ||
header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) | ||
if custom_headers: | ||
header_parameters.update(custom_headers) | ||
if self.config.accept_language is not None: | ||
header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') | ||
|
||
# Construct and send request | ||
request = self._client.get(url, query_parameters) | ||
response = self._client.send(request, header_parameters, stream=False, **operation_config) | ||
|
||
if response.status_code not in [200]: | ||
exp = CloudError(response) | ||
exp.request_id = response.headers.get('x-ms-request-id') | ||
raise exp | ||
|
||
deserialized = None | ||
|
||
if response.status_code == 200: | ||
deserialized = self._deserialize('Permissions', response) | ||
|
||
if raw: | ||
client_raw_response = ClientRawResponse(deserialized, response) | ||
return client_raw_response | ||
|
||
return deserialized | ||
get.metadata = {'url': '/{tenantID}/oauth2PermissionGrants'} | ||
|
||
def post( | ||
self, body=None, custom_headers=None, raw=False, **operation_config): | ||
"""Grants OAuth2 permissions for the relevant resource Ids of an app. | ||
:param body: The relevant app Service Principal Object Id and the | ||
Service Principal Objecit Id you want to grant. | ||
:type body: ~azure.graphrbac.models.Permissions | ||
:param dict custom_headers: headers that will be added to the request | ||
:param bool raw: returns the direct response alongside the | ||
deserialized response | ||
:param operation_config: :ref:`Operation configuration | ||
overrides<msrest:optionsforoperations>`. | ||
:return: Permissions or ClientRawResponse if raw=true | ||
:rtype: ~azure.graphrbac.models.Permissions or | ||
~msrest.pipeline.ClientRawResponse | ||
:raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` | ||
""" | ||
# Construct URL | ||
url = self.post.metadata['url'] | ||
path_format_arguments = { | ||
'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str') | ||
} | ||
url = self._client.format_url(url, **path_format_arguments) | ||
|
||
# Construct parameters | ||
query_parameters = {} | ||
query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') | ||
|
||
# Construct headers | ||
header_parameters = {} | ||
header_parameters['Content-Type'] = 'application/json; charset=utf-8' | ||
if self.config.generate_client_request_id: | ||
header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) | ||
if custom_headers: | ||
header_parameters.update(custom_headers) | ||
if self.config.accept_language is not None: | ||
header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') | ||
|
||
# Construct body | ||
if body is not None: | ||
body_content = self._serialize.body(body, 'Permissions') | ||
else: | ||
body_content = None | ||
|
||
# Construct and send request | ||
request = self._client.post(url, query_parameters) | ||
response = self._client.send( | ||
request, header_parameters, body_content, stream=False, **operation_config) | ||
|
||
if response.status_code not in [201]: | ||
exp = CloudError(response) | ||
exp.request_id = response.headers.get('x-ms-request-id') | ||
raise exp | ||
|
||
deserialized = None | ||
|
||
if response.status_code == 201: | ||
deserialized = self._deserialize('Permissions', response) | ||
|
||
if raw: | ||
client_raw_response = ClientRawResponse(deserialized, response) | ||
return client_raw_response | ||
|
||
return deserialized | ||
post.metadata = {'url': '/{tenantID}/oauth2PermissionGrants'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters