|
| 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) Python 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, Optional, TYPE_CHECKING, cast |
| 11 | +from typing_extensions import Self |
| 12 | + |
| 13 | +from azure.core.pipeline import policies |
| 14 | +from azure.core.rest import HttpRequest, HttpResponse |
| 15 | +from azure.core.settings import settings |
| 16 | +from azure.mgmt.core import ARMPipelineClient |
| 17 | +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy |
| 18 | +from azure.mgmt.core.tools import get_arm_endpoints |
| 19 | + |
| 20 | +from ._configuration import ElasticClientConfiguration |
| 21 | +from ._utils.serialization import Deserializer, Serializer |
| 22 | +from .operations import ( |
| 23 | + ElasticMonitorResourcesOperations, |
| 24 | + ElasticVersionsOperationGroupOperations, |
| 25 | + MonitoredSubscriptionsOperations, |
| 26 | + OpenAIIntegrationRPModelsOperations, |
| 27 | + Operations, |
| 28 | + OrganizationsOperationGroupOperations, |
| 29 | + TagRulesOperations, |
| 30 | +) |
| 31 | + |
| 32 | +if TYPE_CHECKING: |
| 33 | + from azure.core.credentials import TokenCredential |
| 34 | + |
| 35 | + |
| 36 | +class ElasticClient: # pylint: disable=too-many-instance-attributes |
| 37 | + """ElasticClient. |
| 38 | +
|
| 39 | + :ivar operations: Operations operations |
| 40 | + :vartype operations: azure.mgmt.elastic.operations.Operations |
| 41 | + :ivar elastic_monitor_resources: ElasticMonitorResourcesOperations operations |
| 42 | + :vartype elastic_monitor_resources: |
| 43 | + azure.mgmt.elastic.operations.ElasticMonitorResourcesOperations |
| 44 | + :ivar monitored_subscriptions: MonitoredSubscriptionsOperations operations |
| 45 | + :vartype monitored_subscriptions: |
| 46 | + azure.mgmt.elastic.operations.MonitoredSubscriptionsOperations |
| 47 | + :ivar open_ai_integration_rp_models: OpenAIIntegrationRPModelsOperations operations |
| 48 | + :vartype open_ai_integration_rp_models: |
| 49 | + azure.mgmt.elastic.operations.OpenAIIntegrationRPModelsOperations |
| 50 | + :ivar tag_rules: TagRulesOperations operations |
| 51 | + :vartype tag_rules: azure.mgmt.elastic.operations.TagRulesOperations |
| 52 | + :ivar elastic_versions_operation_group: ElasticVersionsOperationGroupOperations operations |
| 53 | + :vartype elastic_versions_operation_group: |
| 54 | + azure.mgmt.elastic.operations.ElasticVersionsOperationGroupOperations |
| 55 | + :ivar organizations_operation_group: OrganizationsOperationGroupOperations operations |
| 56 | + :vartype organizations_operation_group: |
| 57 | + azure.mgmt.elastic.operations.OrganizationsOperationGroupOperations |
| 58 | + :param credential: Credential used to authenticate requests to the service. Required. |
| 59 | + :type credential: ~azure.core.credentials.TokenCredential |
| 60 | + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. |
| 61 | + :type subscription_id: str |
| 62 | + :param base_url: Service host. Default value is None. |
| 63 | + :type base_url: str |
| 64 | + :keyword api_version: The API version to use for this operation. Default value is |
| 65 | + "2025-01-15-preview". Note that overriding this default value may result in unsupported |
| 66 | + behavior. |
| 67 | + :paramtype api_version: str |
| 68 | + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no |
| 69 | + Retry-After header is present. |
| 70 | + """ |
| 71 | + |
| 72 | + def __init__( |
| 73 | + self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any |
| 74 | + ) -> None: |
| 75 | + _endpoint = "{endpoint}" |
| 76 | + _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore |
| 77 | + _endpoints = get_arm_endpoints(_cloud) |
| 78 | + if not base_url: |
| 79 | + base_url = _endpoints["resource_manager"] |
| 80 | + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) |
| 81 | + self._config = ElasticClientConfiguration( |
| 82 | + credential=credential, |
| 83 | + subscription_id=subscription_id, |
| 84 | + base_url=cast(str, base_url), |
| 85 | + credential_scopes=credential_scopes, |
| 86 | + **kwargs |
| 87 | + ) |
| 88 | + |
| 89 | + _policies = kwargs.pop("policies", None) |
| 90 | + if _policies is None: |
| 91 | + _policies = [ |
| 92 | + policies.RequestIdPolicy(**kwargs), |
| 93 | + self._config.headers_policy, |
| 94 | + self._config.user_agent_policy, |
| 95 | + self._config.proxy_policy, |
| 96 | + policies.ContentDecodePolicy(**kwargs), |
| 97 | + ARMAutoResourceProviderRegistrationPolicy(), |
| 98 | + self._config.redirect_policy, |
| 99 | + self._config.retry_policy, |
| 100 | + self._config.authentication_policy, |
| 101 | + self._config.custom_hook_policy, |
| 102 | + self._config.logging_policy, |
| 103 | + policies.DistributedTracingPolicy(**kwargs), |
| 104 | + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, |
| 105 | + self._config.http_logging_policy, |
| 106 | + ] |
| 107 | + self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, _endpoint), policies=_policies, **kwargs) |
| 108 | + |
| 109 | + self._serialize = Serializer() |
| 110 | + self._deserialize = Deserializer() |
| 111 | + self._serialize.client_side_validation = False |
| 112 | + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) |
| 113 | + self.elastic_monitor_resources = ElasticMonitorResourcesOperations( |
| 114 | + self._client, self._config, self._serialize, self._deserialize |
| 115 | + ) |
| 116 | + self.monitored_subscriptions = MonitoredSubscriptionsOperations( |
| 117 | + self._client, self._config, self._serialize, self._deserialize |
| 118 | + ) |
| 119 | + self.open_ai_integration_rp_models = OpenAIIntegrationRPModelsOperations( |
| 120 | + self._client, self._config, self._serialize, self._deserialize |
| 121 | + ) |
| 122 | + self.tag_rules = TagRulesOperations(self._client, self._config, self._serialize, self._deserialize) |
| 123 | + self.elastic_versions_operation_group = ElasticVersionsOperationGroupOperations( |
| 124 | + self._client, self._config, self._serialize, self._deserialize |
| 125 | + ) |
| 126 | + self.organizations_operation_group = OrganizationsOperationGroupOperations( |
| 127 | + self._client, self._config, self._serialize, self._deserialize |
| 128 | + ) |
| 129 | + |
| 130 | + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: |
| 131 | + """Runs the network request through the client's chained policies. |
| 132 | +
|
| 133 | + >>> from azure.core.rest import HttpRequest |
| 134 | + >>> request = HttpRequest("GET", "https://www.example.org/") |
| 135 | + <HttpRequest [GET], url: 'https://www.example.org/'> |
| 136 | + >>> response = client.send_request(request) |
| 137 | + <HttpResponse: 200 OK> |
| 138 | +
|
| 139 | + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request |
| 140 | +
|
| 141 | + :param request: The network request you want to make. Required. |
| 142 | + :type request: ~azure.core.rest.HttpRequest |
| 143 | + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. |
| 144 | + :return: The response of your network call. Does not do error handling on your response. |
| 145 | + :rtype: ~azure.core.rest.HttpResponse |
| 146 | + """ |
| 147 | + |
| 148 | + request_copy = deepcopy(request) |
| 149 | + path_format_arguments = { |
| 150 | + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), |
| 151 | + } |
| 152 | + |
| 153 | + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) |
| 154 | + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore |
| 155 | + |
| 156 | + def close(self) -> None: |
| 157 | + self._client.close() |
| 158 | + |
| 159 | + def __enter__(self) -> Self: |
| 160 | + self._client.__enter__() |
| 161 | + return self |
| 162 | + |
| 163 | + def __exit__(self, *exc_details: Any) -> None: |
| 164 | + self._client.__exit__(*exc_details) |
0 commit comments