|
| 1 | +# coding=utf-8 |
| 2 | +# -------------------------------------------------------------------------- |
| 3 | +# Copyright (c) Microsoft Corporation. All rights reserved. |
| 4 | +# Licensed under the MIT License. See License.txt in the project root for license information. |
| 5 | +# Code generated by Microsoft (R) AutoRest Code Generator. |
| 6 | +# Changes may cause incorrect behavior and will be lost if the code is regenerated. |
| 7 | +# -------------------------------------------------------------------------- |
| 8 | + |
| 9 | +from copy import deepcopy |
| 10 | +from typing import Any, TYPE_CHECKING |
| 11 | + |
| 12 | +from azure.core.rest import HttpRequest, HttpResponse |
| 13 | +from azure.mgmt.core import ARMPipelineClient |
| 14 | + |
| 15 | +from . import models as _models |
| 16 | +from ._configuration import CosmosDBForPostgreSQLConfiguration |
| 17 | +from ._serialization import Deserializer, Serializer |
| 18 | +from .operations import ( |
| 19 | + ClustersOperations, |
| 20 | + ConfigurationsOperations, |
| 21 | + FirewallRulesOperations, |
| 22 | + Operations, |
| 23 | + PrivateEndpointConnectionsOperations, |
| 24 | + PrivateLinkResourcesOperations, |
| 25 | + RolesOperations, |
| 26 | + ServersOperations, |
| 27 | +) |
| 28 | + |
| 29 | +if TYPE_CHECKING: |
| 30 | + # pylint: disable=unused-import,ungrouped-imports |
| 31 | + from azure.core.credentials import TokenCredential |
| 32 | + |
| 33 | + |
| 34 | +class CosmosDBForPostgreSQL: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes |
| 35 | + """The Microsoft Azure management API provides create, read, update, and delete functionality for |
| 36 | + Cosmos DB for PostgreSQL resources including clusters, servers, configurations, firewall rules, |
| 37 | + roles, private endpoint connections and private link resources. |
| 38 | +
|
| 39 | + :ivar clusters: ClustersOperations operations |
| 40 | + :vartype clusters: azure.mgmt.rdbms.postgresqlhsc.operations.ClustersOperations |
| 41 | + :ivar servers: ServersOperations operations |
| 42 | + :vartype servers: azure.mgmt.rdbms.postgresqlhsc.operations.ServersOperations |
| 43 | + :ivar configurations: ConfigurationsOperations operations |
| 44 | + :vartype configurations: azure.mgmt.rdbms.postgresqlhsc.operations.ConfigurationsOperations |
| 45 | + :ivar firewall_rules: FirewallRulesOperations operations |
| 46 | + :vartype firewall_rules: azure.mgmt.rdbms.postgresqlhsc.operations.FirewallRulesOperations |
| 47 | + :ivar roles: RolesOperations operations |
| 48 | + :vartype roles: azure.mgmt.rdbms.postgresqlhsc.operations.RolesOperations |
| 49 | + :ivar operations: Operations operations |
| 50 | + :vartype operations: azure.mgmt.rdbms.postgresqlhsc.operations.Operations |
| 51 | + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations |
| 52 | + :vartype private_endpoint_connections: |
| 53 | + azure.mgmt.rdbms.postgresqlhsc.operations.PrivateEndpointConnectionsOperations |
| 54 | + :ivar private_link_resources: PrivateLinkResourcesOperations operations |
| 55 | + :vartype private_link_resources: |
| 56 | + azure.mgmt.rdbms.postgresqlhsc.operations.PrivateLinkResourcesOperations |
| 57 | + :param credential: Credential needed for the client to connect to Azure. Required. |
| 58 | + :type credential: ~azure.core.credentials.TokenCredential |
| 59 | + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. |
| 60 | + :type subscription_id: str |
| 61 | + :param base_url: Service URL. Default value is "https://management.azure.com". |
| 62 | + :type base_url: str |
| 63 | + :keyword api_version: Api Version. Default value is "2022-11-08". Note that overriding this |
| 64 | + default value may result in unsupported behavior. |
| 65 | + :paramtype api_version: str |
| 66 | + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no |
| 67 | + Retry-After header is present. |
| 68 | + """ |
| 69 | + |
| 70 | + def __init__( |
| 71 | + self, |
| 72 | + credential: "TokenCredential", |
| 73 | + subscription_id: str, |
| 74 | + base_url: str = "https://management.azure.com", |
| 75 | + **kwargs: Any |
| 76 | + ) -> None: |
| 77 | + self._config = CosmosDBForPostgreSQLConfiguration( |
| 78 | + credential=credential, subscription_id=subscription_id, **kwargs |
| 79 | + ) |
| 80 | + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) |
| 81 | + |
| 82 | + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} |
| 83 | + self._serialize = Serializer(client_models) |
| 84 | + self._deserialize = Deserializer(client_models) |
| 85 | + self._serialize.client_side_validation = False |
| 86 | + self.clusters = ClustersOperations(self._client, self._config, self._serialize, self._deserialize) |
| 87 | + self.servers = ServersOperations(self._client, self._config, self._serialize, self._deserialize) |
| 88 | + self.configurations = ConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 89 | + self.firewall_rules = FirewallRulesOperations(self._client, self._config, self._serialize, self._deserialize) |
| 90 | + self.roles = RolesOperations(self._client, self._config, self._serialize, self._deserialize) |
| 91 | + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) |
| 92 | + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( |
| 93 | + self._client, self._config, self._serialize, self._deserialize |
| 94 | + ) |
| 95 | + self.private_link_resources = PrivateLinkResourcesOperations( |
| 96 | + self._client, self._config, self._serialize, self._deserialize |
| 97 | + ) |
| 98 | + |
| 99 | + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: |
| 100 | + """Runs the network request through the client's chained policies. |
| 101 | +
|
| 102 | + >>> from azure.core.rest import HttpRequest |
| 103 | + >>> request = HttpRequest("GET", "https://www.example.org/") |
| 104 | + <HttpRequest [GET], url: 'https://www.example.org/'> |
| 105 | + >>> response = client._send_request(request) |
| 106 | + <HttpResponse: 200 OK> |
| 107 | +
|
| 108 | + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request |
| 109 | +
|
| 110 | + :param request: The network request you want to make. Required. |
| 111 | + :type request: ~azure.core.rest.HttpRequest |
| 112 | + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. |
| 113 | + :return: The response of your network call. Does not do error handling on your response. |
| 114 | + :rtype: ~azure.core.rest.HttpResponse |
| 115 | + """ |
| 116 | + |
| 117 | + request_copy = deepcopy(request) |
| 118 | + request_copy.url = self._client.format_url(request_copy.url) |
| 119 | + return self._client.send_request(request_copy, **kwargs) |
| 120 | + |
| 121 | + def close(self) -> None: |
| 122 | + self._client.close() |
| 123 | + |
| 124 | + def __enter__(self) -> "CosmosDBForPostgreSQL": |
| 125 | + self._client.__enter__() |
| 126 | + return self |
| 127 | + |
| 128 | + def __exit__(self, *exc_details: Any) -> None: |
| 129 | + self._client.__exit__(*exc_details) |
0 commit comments