From 7396427bde30d1905e894410f9c32410ce9b8695 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Tue, 30 Jan 2018 18:57:37 +0000 Subject: [PATCH] Generated from d3af35e544597c1af44ceae46b86524b86d548e8 [ADLA - ADLS] - Adding pageable extension for Catalog ACL APIs and removing childrenNum property (#2353) * Adding paging for ListAcls and ListAclsByDatabase * Although paging is not supported for these operations, the design decision that we took was to provide support at the client side just in case we need to add it from the server side. * Removing default response from Swagger for Acl APIs * Removing childrenNum property from FileStatusProperties * This property is always null as brought up by this issue: https://github.com/Azure/azure-sdk-for-net/issues/3770 * Fixing examples for childrenNum * Fixing oav validate-example errors --- .../analytics/catalog/models/__init__.py | 4 +- .../analytics/catalog/models/acl_list.py | 35 --- .../analytics/catalog/models/acl_paged.py | 27 ++ .../catalog/operations/catalog_operations.py | 282 ++++++++++-------- 4 files changed, 179 insertions(+), 169 deletions(-) delete mode 100644 azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/models/acl_list.py create mode 100644 azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/models/acl_paged.py diff --git a/azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/models/__init__.py b/azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/models/__init__.py index ddf39e7edca5..fa539a690a38 100644 --- a/azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/models/__init__.py +++ b/azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/models/__init__.py @@ -12,7 +12,6 @@ from .acl_create_or_update_parameters import AclCreateOrUpdateParameters from .acl_delete_parameters import AclDeleteParameters from .acl import Acl -from .acl_list import AclList from .data_lake_analytics_catalog_secret_create_or_update_parameters import DataLakeAnalyticsCatalogSecretCreateOrUpdateParameters from .data_lake_analytics_catalog_credential_create_parameters import DataLakeAnalyticsCatalogCredentialCreateParameters from .data_lake_analytics_catalog_credential_delete_parameters import DataLakeAnalyticsCatalogCredentialDeleteParameters @@ -58,6 +57,7 @@ from .usql_table_valued_function_paged import USqlTableValuedFunctionPaged from .usql_assembly_clr_paged import USqlAssemblyClrPaged from .usql_schema_paged import USqlSchemaPaged +from .acl_paged import AclPaged from .usql_database_paged import USqlDatabasePaged from .data_lake_analytics_catalog_management_client_enums import ( AclType, @@ -69,7 +69,6 @@ 'AclCreateOrUpdateParameters', 'AclDeleteParameters', 'Acl', - 'AclList', 'DataLakeAnalyticsCatalogSecretCreateOrUpdateParameters', 'DataLakeAnalyticsCatalogCredentialCreateParameters', 'DataLakeAnalyticsCatalogCredentialDeleteParameters', @@ -115,6 +114,7 @@ 'USqlTableValuedFunctionPaged', 'USqlAssemblyClrPaged', 'USqlSchemaPaged', + 'AclPaged', 'USqlDatabasePaged', 'AclType', 'PermissionType', diff --git a/azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/models/acl_list.py b/azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/models/acl_list.py deleted file mode 100644 index 9009400a43d7..000000000000 --- a/azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/models/acl_list.py +++ /dev/null @@ -1,35 +0,0 @@ -# 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 AclList(Model): - """A Data Lake Analytics catalog access control list (ACL). - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar value: the access control list (ACL). - :vartype value: list[~azure.mgmt.datalake.analytics.catalog.models.Acl] - """ - - _validation = { - 'value': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Acl]'}, - } - - def __init__(self): - super(AclList, self).__init__() - self.value = None diff --git a/azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/models/acl_paged.py b/azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/models/acl_paged.py new file mode 100644 index 000000000000..ce838fae2933 --- /dev/null +++ b/azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/models/acl_paged.py @@ -0,0 +1,27 @@ +# 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.paging import Paged + + +class AclPaged(Paged): + """ + A paging container for iterating over a list of :class:`Acl ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[Acl]'} + } + + def __init__(self, *args, **kwargs): + + super(AclPaged, self).__init__(*args, **kwargs) diff --git a/azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/operations/catalog_operations.py b/azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/operations/catalog_operations.py index a51f609fd078..7106dfcaa679 100644 --- a/azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/operations/catalog_operations.py +++ b/azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/operations/catalog_operations.py @@ -3389,62 +3389,71 @@ def list_acls_by_database( deserialized response :param operation_config: :ref:`Operation configuration overrides`. - :return: AclList or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.datalake.analytics.catalog.models.AclList or - ~msrest.pipeline.ClientRawResponse + :return: An iterator like instance of Acl + :rtype: + ~azure.mgmt.datalake.analytics.catalog.models.AclPaged[~azure.mgmt.datalake.analytics.catalog.models.Acl] :raises: :class:`CloudError` """ - # Construct URL - url = '/catalog/usql/databases/{databaseName}/acl' - path_format_arguments = { - 'accountName': self._serialize.url("account_name", account_name, 'str', skip_quote=True), - 'adlaCatalogDnsSuffix': self._serialize.url("self.config.adla_catalog_dns_suffix", self.config.adla_catalog_dns_suffix, 'str', skip_quote=True), - 'databaseName': self._serialize.url("database_name", database_name, 'str') - } - url = self._client.format_url(url, **path_format_arguments) + def internal_paging(next_link=None, raw=False): - # Construct parameters - query_parameters = {} - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=1) - if select is not None: - query_parameters['$select'] = self._serialize.query("select", select, 'str') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - if count is not None: - query_parameters['$count'] = self._serialize.query("count", count, 'bool') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if not next_link: + # Construct URL + url = '/catalog/usql/databases/{databaseName}/acl' + path_format_arguments = { + 'accountName': self._serialize.url("account_name", account_name, 'str', skip_quote=True), + 'adlaCatalogDnsSuffix': self._serialize.url("self.config.adla_catalog_dns_suffix", self.config.adla_catalog_dns_suffix, 'str', skip_quote=True), + 'databaseName': self._serialize.url("database_name", database_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) - # 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 parameters + query_parameters = {} + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=1) + if select is not None: + query_parameters['$select'] = self._serialize.query("select", select, 'str') + if orderby is not None: + query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') + if count is not None: + query_parameters['$count'] = self._serialize.query("count", count, 'bool') + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) + else: + url = next_link + query_parameters = {} - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + # 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') - deserialized = None + # 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 == 200: - deserialized = self._deserialize('AclList', response) + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + return response + + # Deserialize response + deserialized = models.AclPaged(internal_paging, self._deserialize.dependencies) if raw: - client_raw_response = ClientRawResponse(deserialized, response) + header_dict = {} + client_raw_response = models.AclPaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized @@ -3482,61 +3491,70 @@ def list_acls( deserialized response :param operation_config: :ref:`Operation configuration overrides`. - :return: AclList or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.datalake.analytics.catalog.models.AclList or - ~msrest.pipeline.ClientRawResponse + :return: An iterator like instance of Acl + :rtype: + ~azure.mgmt.datalake.analytics.catalog.models.AclPaged[~azure.mgmt.datalake.analytics.catalog.models.Acl] :raises: :class:`CloudError` """ - # Construct URL - url = '/catalog/usql/acl' - path_format_arguments = { - 'accountName': self._serialize.url("account_name", account_name, 'str', skip_quote=True), - 'adlaCatalogDnsSuffix': self._serialize.url("self.config.adla_catalog_dns_suffix", self.config.adla_catalog_dns_suffix, 'str', skip_quote=True) - } - url = self._client.format_url(url, **path_format_arguments) + def internal_paging(next_link=None, raw=False): - # Construct parameters - query_parameters = {} - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=1) - if select is not None: - query_parameters['$select'] = self._serialize.query("select", select, 'str') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - if count is not None: - query_parameters['$count'] = self._serialize.query("count", count, 'bool') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if not next_link: + # Construct URL + url = '/catalog/usql/acl' + path_format_arguments = { + 'accountName': self._serialize.url("account_name", account_name, 'str', skip_quote=True), + 'adlaCatalogDnsSuffix': self._serialize.url("self.config.adla_catalog_dns_suffix", self.config.adla_catalog_dns_suffix, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) - # 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 parameters + query_parameters = {} + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=1) + if select is not None: + query_parameters['$select'] = self._serialize.query("select", select, 'str') + if orderby is not None: + query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') + if count is not None: + query_parameters['$count'] = self._serialize.query("count", count, 'bool') + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) + else: + url = next_link + query_parameters = {} - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + # 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') - deserialized = None + # 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 == 200: - deserialized = self._deserialize('AclList', response) + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + return response + + # Deserialize response + deserialized = models.AclPaged(internal_paging, self._deserialize.dependencies) if raw: - client_raw_response = ClientRawResponse(deserialized, response) + header_dict = {} + client_raw_response = models.AclPaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized @@ -3703,18 +3721,16 @@ def internal_paging(next_link=None, raw=False): return deserialized - def grant_acl_to_database( - self, account_name, database_name, parameters, custom_headers=None, raw=False, **operation_config): - """Grants an access control list (ACL) entry to the database from the Data - Lake Analytics catalog. + def grant_acl( + self, account_name, parameters, custom_headers=None, raw=False, **operation_config): + """Grants an access control list (ACL) entry to the Data Lake Analytics + catalog. :param account_name: The Azure Data Lake Analytics account upon which to execute catalog operations. :type account_name: str - :param database_name: The name of the database. - :type database_name: str :param parameters: Parameters supplied to create or update an access - control list (ACL) entry for a database. + control list (ACL) entry for a Data Lake Analytics catalog. :type parameters: ~azure.mgmt.datalake.analytics.catalog.models.AclCreateOrUpdateParameters :param dict custom_headers: headers that will be added to the request @@ -3729,11 +3745,10 @@ def grant_acl_to_database( op = "GRANTACE" # Construct URL - url = '/catalog/usql/databases/{databaseName}/acl' + url = '/catalog/usql/acl' path_format_arguments = { 'accountName': self._serialize.url("account_name", account_name, 'str', skip_quote=True), - 'adlaCatalogDnsSuffix': self._serialize.url("self.config.adla_catalog_dns_suffix", self.config.adla_catalog_dns_suffix, 'str', skip_quote=True), - 'databaseName': self._serialize.url("database_name", database_name, 'str') + 'adlaCatalogDnsSuffix': self._serialize.url("self.config.adla_catalog_dns_suffix", self.config.adla_catalog_dns_suffix, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) @@ -3769,24 +3784,20 @@ def grant_acl_to_database( client_raw_response = ClientRawResponse(None, response) return client_raw_response - def revoke_acl_from_database( - self, account_name, database_name, ace_type, principal_id, custom_headers=None, raw=False, **operation_config): - """Revokes an access control list (ACL) entry for the database from the - Data Lake Analytics catalog. + def grant_acl_to_database( + self, account_name, database_name, parameters, custom_headers=None, raw=False, **operation_config): + """Grants an access control list (ACL) entry to the database from the Data + Lake Analytics catalog. :param account_name: The Azure Data Lake Analytics account upon which to execute catalog operations. :type account_name: str :param database_name: The name of the database. :type database_name: str - :param ace_type: the access control list (ACL) entry type. UserObj and - GroupObj denote the owning user and group, respectively. Possible - values include: 'UserObj', 'GroupObj', 'Other', 'User', 'Group' - :type ace_type: str or - ~azure.mgmt.datalake.analytics.catalog.models.AclType - :param principal_id: the Azure AD object ID of the user or group being - specified in the access control list (ACL) entry. - :type principal_id: str + :param parameters: Parameters supplied to create or update an access + control list (ACL) entry for a database. + :type parameters: + ~azure.mgmt.datalake.analytics.catalog.models.AclCreateOrUpdateParameters :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -3796,9 +3807,7 @@ def revoke_acl_from_database( :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError` """ - parameters = models.AclDeleteParameters(ace_type=ace_type, principal_id=principal_id) - - op = "REVOKEACE" + op = "GRANTACE" # Construct URL url = '/catalog/usql/databases/{databaseName}/acl' @@ -3825,7 +3834,7 @@ def revoke_acl_from_database( header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body - body_content = self._serialize.body(parameters, 'AclDeleteParameters') + body_content = self._serialize.body(parameters, 'AclCreateOrUpdateParameters') # Construct and send request request = self._client.post(url, query_parameters) @@ -3841,18 +3850,22 @@ def revoke_acl_from_database( client_raw_response = ClientRawResponse(None, response) return client_raw_response - def grant_acl( - self, account_name, parameters, custom_headers=None, raw=False, **operation_config): - """Grants an access control list (ACL) entry to the Data Lake Analytics + def revoke_acl( + self, account_name, ace_type, principal_id, custom_headers=None, raw=False, **operation_config): + """Revokes an access control list (ACL) entry from the Data Lake Analytics catalog. :param account_name: The Azure Data Lake Analytics account upon which to execute catalog operations. :type account_name: str - :param parameters: Parameters supplied to create or update an access - control list (ACL) entry for a Data Lake Analytics catalog. - :type parameters: - ~azure.mgmt.datalake.analytics.catalog.models.AclCreateOrUpdateParameters + :param ace_type: the access control list (ACL) entry type. UserObj and + GroupObj denote the owning user and group, respectively. Possible + values include: 'UserObj', 'GroupObj', 'Other', 'User', 'Group' + :type ace_type: str or + ~azure.mgmt.datalake.analytics.catalog.models.AclType + :param principal_id: the Azure AD object ID of the user or group being + specified in the access control list (ACL) entry. + :type principal_id: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -3862,7 +3875,9 @@ def grant_acl( :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError` """ - op = "GRANTACE" + parameters = models.AclDeleteParameters(ace_type=ace_type, principal_id=principal_id) + + op = "REVOKEACE" # Construct URL url = '/catalog/usql/acl' @@ -3888,7 +3903,7 @@ def grant_acl( header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body - body_content = self._serialize.body(parameters, 'AclCreateOrUpdateParameters') + body_content = self._serialize.body(parameters, 'AclDeleteParameters') # Construct and send request request = self._client.post(url, query_parameters) @@ -3904,14 +3919,16 @@ def grant_acl( client_raw_response = ClientRawResponse(None, response) return client_raw_response - def revoke_acl( - self, account_name, ace_type, principal_id, custom_headers=None, raw=False, **operation_config): - """Revokes an access control list (ACL) entry from the Data Lake Analytics - catalog. + def revoke_acl_from_database( + self, account_name, database_name, ace_type, principal_id, custom_headers=None, raw=False, **operation_config): + """Revokes an access control list (ACL) entry for the database from the + Data Lake Analytics catalog. :param account_name: The Azure Data Lake Analytics account upon which to execute catalog operations. :type account_name: str + :param database_name: The name of the database. + :type database_name: str :param ace_type: the access control list (ACL) entry type. UserObj and GroupObj denote the owning user and group, respectively. Possible values include: 'UserObj', 'GroupObj', 'Other', 'User', 'Group' @@ -3934,10 +3951,11 @@ def revoke_acl( op = "REVOKEACE" # Construct URL - url = '/catalog/usql/acl' + url = '/catalog/usql/databases/{databaseName}/acl' path_format_arguments = { 'accountName': self._serialize.url("account_name", account_name, 'str', skip_quote=True), - 'adlaCatalogDnsSuffix': self._serialize.url("self.config.adla_catalog_dns_suffix", self.config.adla_catalog_dns_suffix, 'str', skip_quote=True) + 'adlaCatalogDnsSuffix': self._serialize.url("self.config.adla_catalog_dns_suffix", self.config.adla_catalog_dns_suffix, 'str', skip_quote=True), + 'databaseName': self._serialize.url("database_name", database_name, 'str') } url = self._client.format_url(url, **path_format_arguments)