diff --git a/azure-mgmt-kusto/MANIFEST.in b/azure-mgmt-kusto/MANIFEST.in index 6ceb27f7a96e..e4884efef41b 100644 --- a/azure-mgmt-kusto/MANIFEST.in +++ b/azure-mgmt-kusto/MANIFEST.in @@ -1,3 +1,4 @@ +recursive-include tests *.py *.yaml include *.rst include azure/__init__.py include azure/mgmt/__init__.py diff --git a/azure-mgmt-kusto/azure/mgmt/kusto/models/__init__.py b/azure-mgmt-kusto/azure/mgmt/kusto/models/__init__.py index 609dec3cb394..950d7582ad2e 100644 --- a/azure-mgmt-kusto/azure/mgmt/kusto/models/__init__.py +++ b/azure-mgmt-kusto/azure/mgmt/kusto/models/__init__.py @@ -30,6 +30,7 @@ from .data_connection_validation_list_result_py3 import DataConnectionValidationListResult from .cluster_check_name_request_py3 import ClusterCheckNameRequest from .database_check_name_request_py3 import DatabaseCheckNameRequest + from .data_connection_check_name_request_py3 import DataConnectionCheckNameRequest from .check_name_result_py3 import CheckNameResult from .operation_display_py3 import OperationDisplay from .operation_py3 import Operation @@ -58,6 +59,7 @@ from .data_connection_validation_list_result import DataConnectionValidationListResult from .cluster_check_name_request import ClusterCheckNameRequest from .database_check_name_request import DatabaseCheckNameRequest + from .data_connection_check_name_request import DataConnectionCheckNameRequest from .check_name_result import CheckNameResult from .operation_display import OperationDisplay from .operation import Operation @@ -80,6 +82,7 @@ DataFormat, DatabasePrincipalRole, DatabasePrincipalType, + Reason, ) __all__ = [ @@ -103,6 +106,7 @@ 'DataConnectionValidationListResult', 'ClusterCheckNameRequest', 'DatabaseCheckNameRequest', + 'DataConnectionCheckNameRequest', 'CheckNameResult', 'OperationDisplay', 'Operation', @@ -124,4 +128,5 @@ 'DataFormat', 'DatabasePrincipalRole', 'DatabasePrincipalType', + 'Reason', ] diff --git a/azure-mgmt-kusto/azure/mgmt/kusto/models/check_name_result.py b/azure-mgmt-kusto/azure/mgmt/kusto/models/check_name_result.py index 035e47b11bc7..28c9a31746ae 100644 --- a/azure-mgmt-kusto/azure/mgmt/kusto/models/check_name_result.py +++ b/azure-mgmt-kusto/azure/mgmt/kusto/models/check_name_result.py @@ -23,12 +23,16 @@ class CheckNameResult(Model): :param message: Message indicating an unavailable name due to a conflict, or a description of the naming rules that are violated. :type message: str + :param reason: Message providing the reason why the given name is invalid. + Possible values include: 'Invalid', 'AlreadyExists' + :type reason: str or ~azure.mgmt.kusto.models.Reason """ _attribute_map = { 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, 'name': {'key': 'name', 'type': 'str'}, 'message': {'key': 'message', 'type': 'str'}, + 'reason': {'key': 'reason', 'type': 'str'}, } def __init__(self, **kwargs): @@ -36,3 +40,4 @@ def __init__(self, **kwargs): self.name_available = kwargs.get('name_available', None) self.name = kwargs.get('name', None) self.message = kwargs.get('message', None) + self.reason = kwargs.get('reason', None) diff --git a/azure-mgmt-kusto/azure/mgmt/kusto/models/check_name_result_py3.py b/azure-mgmt-kusto/azure/mgmt/kusto/models/check_name_result_py3.py index 56f03c29ee41..91edde6bcb30 100644 --- a/azure-mgmt-kusto/azure/mgmt/kusto/models/check_name_result_py3.py +++ b/azure-mgmt-kusto/azure/mgmt/kusto/models/check_name_result_py3.py @@ -23,16 +23,21 @@ class CheckNameResult(Model): :param message: Message indicating an unavailable name due to a conflict, or a description of the naming rules that are violated. :type message: str + :param reason: Message providing the reason why the given name is invalid. + Possible values include: 'Invalid', 'AlreadyExists' + :type reason: str or ~azure.mgmt.kusto.models.Reason """ _attribute_map = { 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, 'name': {'key': 'name', 'type': 'str'}, 'message': {'key': 'message', 'type': 'str'}, + 'reason': {'key': 'reason', 'type': 'str'}, } - def __init__(self, *, name_available: bool=None, name: str=None, message: str=None, **kwargs) -> None: + def __init__(self, *, name_available: bool=None, name: str=None, message: str=None, reason=None, **kwargs) -> None: super(CheckNameResult, self).__init__(**kwargs) self.name_available = name_available self.name = name self.message = message + self.reason = reason diff --git a/azure-mgmt-kusto/azure/mgmt/kusto/models/data_connection_check_name_request.py b/azure-mgmt-kusto/azure/mgmt/kusto/models/data_connection_check_name_request.py new file mode 100644 index 000000000000..2c31aa72d291 --- /dev/null +++ b/azure-mgmt-kusto/azure/mgmt/kusto/models/data_connection_check_name_request.py @@ -0,0 +1,46 @@ +# 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 DataConnectionCheckNameRequest(Model): + """The result returned from a data connections check name availability + request. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. Data Connection name. + :type name: str + :ivar type: Required. The type of resource, + Microsoft.Kusto/clusters/databases/dataConnections. Default value: + "Microsoft.Kusto/clusters/databases/dataConnections" . + :vartype type: str + """ + + _validation = { + 'name': {'required': True}, + 'type': {'required': True, 'constant': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + type = "Microsoft.Kusto/clusters/databases/dataConnections" + + def __init__(self, **kwargs): + super(DataConnectionCheckNameRequest, self).__init__(**kwargs) + self.name = kwargs.get('name', None) diff --git a/azure-mgmt-kusto/azure/mgmt/kusto/models/data_connection_check_name_request_py3.py b/azure-mgmt-kusto/azure/mgmt/kusto/models/data_connection_check_name_request_py3.py new file mode 100644 index 000000000000..7398e92e5ad5 --- /dev/null +++ b/azure-mgmt-kusto/azure/mgmt/kusto/models/data_connection_check_name_request_py3.py @@ -0,0 +1,46 @@ +# 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 DataConnectionCheckNameRequest(Model): + """The result returned from a data connections check name availability + request. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. Data Connection name. + :type name: str + :ivar type: Required. The type of resource, + Microsoft.Kusto/clusters/databases/dataConnections. Default value: + "Microsoft.Kusto/clusters/databases/dataConnections" . + :vartype type: str + """ + + _validation = { + 'name': {'required': True}, + 'type': {'required': True, 'constant': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + type = "Microsoft.Kusto/clusters/databases/dataConnections" + + def __init__(self, *, name: str, **kwargs) -> None: + super(DataConnectionCheckNameRequest, self).__init__(**kwargs) + self.name = name diff --git a/azure-mgmt-kusto/azure/mgmt/kusto/models/kusto_management_client_enums.py b/azure-mgmt-kusto/azure/mgmt/kusto/models/kusto_management_client_enums.py index e990cf23367b..1f290c65b053 100644 --- a/azure-mgmt-kusto/azure/mgmt/kusto/models/kusto_management_client_enums.py +++ b/azure-mgmt-kusto/azure/mgmt/kusto/models/kusto_management_client_enums.py @@ -82,3 +82,9 @@ class DatabasePrincipalType(str, Enum): app = "App" group = "Group" user = "User" + + +class Reason(str, Enum): + + invalid = "Invalid" + already_exists = "AlreadyExists" diff --git a/azure-mgmt-kusto/azure/mgmt/kusto/operations/data_connections_operations.py b/azure-mgmt-kusto/azure/mgmt/kusto/operations/data_connections_operations.py index 17e0bce9bdca..5a51b776aa4a 100644 --- a/azure-mgmt-kusto/azure/mgmt/kusto/operations/data_connections_operations.py +++ b/azure-mgmt-kusto/azure/mgmt/kusto/operations/data_connections_operations.py @@ -190,6 +190,81 @@ def data_connection_validation_method( return deserialized data_connection_validation_method.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnectionValidation'} + def check_name_availability( + self, resource_group_name, cluster_name, database_name, name, custom_headers=None, raw=False, **operation_config): + """Checks that the data connection name is valid and is not already in + use. + + :param resource_group_name: The name of the resource group containing + the Kusto cluster. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. + :type database_name: str + :param name: Data Connection name. + :type name: 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`. + :return: CheckNameResult or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.kusto.models.CheckNameResult or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + data_connection_name = models.DataConnectionCheckNameRequest(name=name) + + # Construct URL + url = self.check_name_availability.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'databaseName': self._serialize.url("database_name", database_name, 'str'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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['Accept'] = 'application/json' + 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 + body_content = self._serialize.body(data_connection_name, 'DataConnectionCheckNameRequest') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, 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('CheckNameResult', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/checkNameAvailability'} + def get( self, resource_group_name, cluster_name, database_name, data_connection_name, custom_headers=None, raw=False, **operation_config): """Returns a data connection. diff --git a/azure-mgmt-kusto/azure/mgmt/kusto/version.py b/azure-mgmt-kusto/azure/mgmt/kusto/version.py index 3e682bbd5fb1..e0ec669828cb 100644 --- a/azure-mgmt-kusto/azure/mgmt/kusto/version.py +++ b/azure-mgmt-kusto/azure/mgmt/kusto/version.py @@ -9,5 +9,5 @@ # regenerated. # -------------------------------------------------------------------------- -VERSION = "0.3.0" +VERSION = "0.1.0" diff --git a/azure-mgmt-kusto/setup.py b/azure-mgmt-kusto/setup.py index 112eab2cff1b..de33718ffe07 100644 --- a/azure-mgmt-kusto/setup.py +++ b/azure-mgmt-kusto/setup.py @@ -53,6 +53,7 @@ version=version, description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), long_description=readme + '\n\n' + history, + long_description_content_type='text/x-rst', license='MIT License', author='Microsoft Corporation', author_email='azpysdkhelp@microsoft.com',