Source code for azure.purview.account.operations._accounts_operations

# 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 functools
from typing import TYPE_CHECKING
import warnings

from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from msrest import Serializer

if TYPE_CHECKING:
    # pylint: disable=unused-import,ungrouped-imports
    from typing import Any, Callable, Dict, Generic, Optional, TypeVar

    T = TypeVar('T')
    ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]

_SERIALIZER = Serializer()
# fmt: off

def build_get_account_properties_request(
    **kwargs  # type: Any
):
    # type: (...) -> HttpRequest
    api_version = "2019-11-01-preview"
    accept = "application/json"
    # Construct URL
    url = kwargs.pop("template_url", '/')

    # Construct parameters
    query_parameters = kwargs.pop("params", {})  # type: Dict[str, Any]
    query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str')

    # Construct headers
    header_parameters = kwargs.pop("headers", {})  # type: Dict[str, Any]
    header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')

    return HttpRequest(
        method="GET",
        url=url,
        params=query_parameters,
        headers=header_parameters,
        **kwargs
    )


def build_update_account_properties_request(
    **kwargs  # type: Any
):
    # type: (...) -> HttpRequest
    content_type = kwargs.pop('content_type', None)  # type: Optional[str]

    api_version = "2019-11-01-preview"
    accept = "application/json"
    # Construct URL
    url = kwargs.pop("template_url", '/')

    # Construct parameters
    query_parameters = kwargs.pop("params", {})  # type: Dict[str, Any]
    query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str')

    # Construct headers
    header_parameters = kwargs.pop("headers", {})  # type: Dict[str, Any]
    if content_type is not None:
        header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str')
    header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')

    return HttpRequest(
        method="PATCH",
        url=url,
        params=query_parameters,
        headers=header_parameters,
        **kwargs
    )


def build_get_access_keys_request(
    **kwargs  # type: Any
):
    # type: (...) -> HttpRequest
    api_version = "2019-11-01-preview"
    accept = "application/json"
    # Construct URL
    url = kwargs.pop("template_url", '/listkeys')

    # Construct parameters
    query_parameters = kwargs.pop("params", {})  # type: Dict[str, Any]
    query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str')

    # Construct headers
    header_parameters = kwargs.pop("headers", {})  # type: Dict[str, Any]
    header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')

    return HttpRequest(
        method="POST",
        url=url,
        params=query_parameters,
        headers=header_parameters,
        **kwargs
    )


def build_regenerate_access_key_request(
    **kwargs  # type: Any
):
    # type: (...) -> HttpRequest
    content_type = kwargs.pop('content_type', None)  # type: Optional[str]

    api_version = "2019-11-01-preview"
    accept = "application/json"
    # Construct URL
    url = kwargs.pop("template_url", '/regeneratekeys')

    # Construct parameters
    query_parameters = kwargs.pop("params", {})  # type: Dict[str, Any]
    query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str')

    # Construct headers
    header_parameters = kwargs.pop("headers", {})  # type: Dict[str, Any]
    if content_type is not None:
        header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str')
    header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')

    return HttpRequest(
        method="POST",
        url=url,
        params=query_parameters,
        headers=header_parameters,
        **kwargs
    )

# fmt: on
[docs]class AccountsOperations(object): """AccountsOperations operations. You should not instantiate this class directly. Instead, you should create a Client instance that instantiates it for you and attaches it as an attribute. :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. """ def __init__(self, client, config, serializer, deserializer): self._client = client self._serialize = serializer self._deserialize = deserializer self._config = config
[docs] @distributed_trace def get_account_properties( self, **kwargs # type: Any ): # type: (...) -> Any """Get an account. :return: JSON object :rtype: Any :raises: ~azure.core.exceptions.HttpResponseError Example: .. code-block:: python # response body for status code(s): 200 response.json() == { "id": "str (optional)", "identity": { "principalId": "str (optional)", "tenantId": "str (optional)", "type": "str (optional)" }, "location": "str (optional)", "name": "str (optional)", "properties": { "cloudConnectors": { "awsExternalId": "str (optional)" }, "createdAt": "datetime (optional)", "createdBy": "str (optional)", "createdByObjectId": "str (optional)", "endpoints": { "catalog": "str (optional)", "guardian": "str (optional)", "scan": "str (optional)" }, "friendlyName": "str (optional)", "managedResourceGroupName": "str (optional)", "managedResources": { "eventHubNamespace": "str (optional)", "resourceGroup": "str (optional)", "storageAccount": "str (optional)" }, "privateEndpointConnections": [ { "id": "str (optional)", "name": "str (optional)", "properties": { "privateEndpoint": { "id": "str (optional)" }, "privateLinkServiceConnectionState": { "actionsRequired": "str (optional)", "description": "str (optional)", "status": "str (optional)" }, "provisioningState": "str (optional)" }, "type": "str (optional)" } ], "provisioningState": "str (optional)", "publicNetworkAccess": "str (optional). Default value is \"Enabled\"" }, "sku": { "capacity": "int (optional)", "name": "str (optional)" }, "systemData": { "createdAt": "datetime (optional)", "createdBy": "str (optional)", "createdByType": "str (optional)", "lastModifiedAt": "datetime (optional)", "lastModifiedBy": "str (optional)", "lastModifiedByType": "str (optional)" }, "tags": { "str": "str (optional)" }, "type": "str (optional)" } """ cls = kwargs.pop('cls', None) # type: ClsType[Any] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) request = build_get_account_properties_request( template_url=self.get_account_properties.metadata['url'], ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } request.url = self._client.format_url(request.url, **path_format_arguments) pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) if response.content: deserialized = response.json() else: deserialized = None if cls: return cls(pipeline_response, deserialized, {}) return deserialized
get_account_properties.metadata = {'url': '/'} # type: ignore
[docs] @distributed_trace def update_account_properties( self, account_update_parameters, # type: Any **kwargs # type: Any ): # type: (...) -> Any """Updates an account. :param account_update_parameters: :type account_update_parameters: Any :return: JSON object :rtype: Any :raises: ~azure.core.exceptions.HttpResponseError Example: .. code-block:: python # JSON input template you can fill out and use as your body input. account_update_parameters = { "friendlyName": "str (optional)" } # response body for status code(s): 200 response.json() == { "id": "str (optional)", "identity": { "principalId": "str (optional)", "tenantId": "str (optional)", "type": "str (optional)" }, "location": "str (optional)", "name": "str (optional)", "properties": { "cloudConnectors": { "awsExternalId": "str (optional)" }, "createdAt": "datetime (optional)", "createdBy": "str (optional)", "createdByObjectId": "str (optional)", "endpoints": { "catalog": "str (optional)", "guardian": "str (optional)", "scan": "str (optional)" }, "friendlyName": "str (optional)", "managedResourceGroupName": "str (optional)", "managedResources": { "eventHubNamespace": "str (optional)", "resourceGroup": "str (optional)", "storageAccount": "str (optional)" }, "privateEndpointConnections": [ { "id": "str (optional)", "name": "str (optional)", "properties": { "privateEndpoint": { "id": "str (optional)" }, "privateLinkServiceConnectionState": { "actionsRequired": "str (optional)", "description": "str (optional)", "status": "str (optional)" }, "provisioningState": "str (optional)" }, "type": "str (optional)" } ], "provisioningState": "str (optional)", "publicNetworkAccess": "str (optional). Default value is \"Enabled\"" }, "sku": { "capacity": "int (optional)", "name": "str (optional)" }, "systemData": { "createdAt": "datetime (optional)", "createdBy": "str (optional)", "createdByType": "str (optional)", "lastModifiedAt": "datetime (optional)", "lastModifiedBy": "str (optional)", "lastModifiedByType": "str (optional)" }, "tags": { "str": "str (optional)" }, "type": "str (optional)" } """ cls = kwargs.pop('cls', None) # type: ClsType[Any] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] json = account_update_parameters request = build_update_account_properties_request( content_type=content_type, json=json, template_url=self.update_account_properties.metadata['url'], ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } request.url = self._client.format_url(request.url, **path_format_arguments) pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) if response.content: deserialized = response.json() else: deserialized = None if cls: return cls(pipeline_response, deserialized, {}) return deserialized
update_account_properties.metadata = {'url': '/'} # type: ignore
[docs] @distributed_trace def get_access_keys( self, **kwargs # type: Any ): # type: (...) -> Any """List the authorization keys associated with this account. :return: JSON object :rtype: Any :raises: ~azure.core.exceptions.HttpResponseError Example: .. code-block:: python # response body for status code(s): 200 response.json() == { "atlasKafkaPrimaryEndpoint": "str (optional)", "atlasKafkaSecondaryEndpoint": "str (optional)" } """ cls = kwargs.pop('cls', None) # type: ClsType[Any] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) request = build_get_access_keys_request( template_url=self.get_access_keys.metadata['url'], ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } request.url = self._client.format_url(request.url, **path_format_arguments) pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) if response.content: deserialized = response.json() else: deserialized = None if cls: return cls(pipeline_response, deserialized, {}) return deserialized
get_access_keys.metadata = {'url': '/listkeys'} # type: ignore
[docs] @distributed_trace def regenerate_access_key( self, key_options, # type: Any **kwargs # type: Any ): # type: (...) -> Any """Regenerate the authorization keys associated with this data catalog. :param key_options: :type key_options: Any :return: JSON object :rtype: Any :raises: ~azure.core.exceptions.HttpResponseError Example: .. code-block:: python # JSON input template you can fill out and use as your body input. key_options = { "keyType": "str (optional)" } # response body for status code(s): 200 response.json() == { "atlasKafkaPrimaryEndpoint": "str (optional)", "atlasKafkaSecondaryEndpoint": "str (optional)" } """ cls = kwargs.pop('cls', None) # type: ClsType[Any] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] json = key_options request = build_regenerate_access_key_request( content_type=content_type, json=json, template_url=self.regenerate_access_key.metadata['url'], ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } request.url = self._client.format_url(request.url, **path_format_arguments) pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) if response.content: deserialized = response.json() else: deserialized = None if cls: return cls(pipeline_response, deserialized, {}) return deserialized
regenerate_access_key.metadata = {'url': '/regeneratekeys'} # type: ignore