-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AutoPR graphrbac/data-plane] Added OAuth2 GET and POST to GraphRBAC.json spec #3063
Merged
AutorestCI
merged 5 commits into
restapi_auto_graphrbac/data-plane
from
restapi_auto_3563
Aug 22, 2018
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
691c960
Generated from 7e6768db7f5cf3600aa596cf9c488c6b5ca34ca2
AutorestCI 31ef19d
Generated from dfc2c5676d5c7be8c4ec55a4356e36cc677ee916
AutorestCI f98df55
Generated from 6aa96687989842d043047ab3b93cd2e5e66b5dd5
AutorestCI 60d5d23
Generated from d2bcb30a79b50cc976ba2b049ff780f8ab8d8292
AutorestCI af70290
Generated from 34825096e936c6c8ee69981113b58cd094f18e8f
AutorestCI File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yugangw-msft This should not be called "post", that's putting in Python API some HTTP verbs for no reason. Should be called "premission_grants".
For instance, what is there is another POST command related to oauth2?
I strongly suggest we rename this based on naming recommendation before merging it.