|
| 1 | +# -------------------------------------------------------------------------------------------- |
| 2 | +# Copyright (c) Microsoft Corporation. All rights reserved. |
| 3 | +# Licensed under the MIT License. See License.txt in the project root for license information. |
| 4 | +# |
| 5 | +# Code generated by aaz-dev-tools |
| 6 | +# -------------------------------------------------------------------------------------------- |
| 7 | + |
| 8 | +# pylint: skip-file |
| 9 | +# flake8: noqa |
| 10 | + |
| 11 | +from azure.cli.core.aaz import * |
| 12 | + |
| 13 | + |
| 14 | +@register_command( |
| 15 | + "elastic get-elastic-organization-to-azure-subscription-mapping", |
| 16 | +) |
| 17 | +class GetElasticOrganizationToAzureSubscriptionMapping(AAZCommand): |
| 18 | + """Retrieve mapping details between the Elastic Organization and Azure Subscription for the logged-in user. |
| 19 | +
|
| 20 | + :example: Organizations_GetElasticToAzureSubscriptionMapping |
| 21 | + az elastic get-elastic-organization-to-azure-subscription-mapping |
| 22 | + """ |
| 23 | + |
| 24 | + _aaz_info = { |
| 25 | + "version": "2025-06-01", |
| 26 | + "resources": [ |
| 27 | + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.elastic/getelasticorganizationtoazuresubscriptionmapping", "2025-06-01"], |
| 28 | + ] |
| 29 | + } |
| 30 | + |
| 31 | + def _handler(self, command_args): |
| 32 | + super()._handler(command_args) |
| 33 | + self._execute_operations() |
| 34 | + return self._output() |
| 35 | + |
| 36 | + _args_schema = None |
| 37 | + |
| 38 | + @classmethod |
| 39 | + def _build_arguments_schema(cls, *args, **kwargs): |
| 40 | + if cls._args_schema is not None: |
| 41 | + return cls._args_schema |
| 42 | + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) |
| 43 | + |
| 44 | + # define Arg Group "" |
| 45 | + return cls._args_schema |
| 46 | + |
| 47 | + def _execute_operations(self): |
| 48 | + self.pre_operations() |
| 49 | + self.OrganizationsGetElasticToAzureSubscriptionMapping(ctx=self.ctx)() |
| 50 | + self.post_operations() |
| 51 | + |
| 52 | + @register_callback |
| 53 | + def pre_operations(self): |
| 54 | + pass |
| 55 | + |
| 56 | + @register_callback |
| 57 | + def post_operations(self): |
| 58 | + pass |
| 59 | + |
| 60 | + def _output(self, *args, **kwargs): |
| 61 | + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=False) |
| 62 | + return result |
| 63 | + |
| 64 | + class OrganizationsGetElasticToAzureSubscriptionMapping(AAZHttpOperation): |
| 65 | + CLIENT_TYPE = "MgmtClient" |
| 66 | + |
| 67 | + def __call__(self, *args, **kwargs): |
| 68 | + request = self.make_request() |
| 69 | + session = self.client.send_request(request=request, stream=False, **kwargs) |
| 70 | + if session.http_response.status_code in [200]: |
| 71 | + return self.on_200(session) |
| 72 | + |
| 73 | + return self.on_error(session.http_response) |
| 74 | + |
| 75 | + @property |
| 76 | + def url(self): |
| 77 | + return self.client.format_url( |
| 78 | + "/subscriptions/{subscriptionId}/providers/Microsoft.Elastic/getElasticOrganizationToAzureSubscriptionMapping", |
| 79 | + **self.url_parameters |
| 80 | + ) |
| 81 | + |
| 82 | + @property |
| 83 | + def method(self): |
| 84 | + return "POST" |
| 85 | + |
| 86 | + @property |
| 87 | + def error_format(self): |
| 88 | + return "ODataV4Format" |
| 89 | + |
| 90 | + @property |
| 91 | + def url_parameters(self): |
| 92 | + parameters = { |
| 93 | + **self.serialize_url_param( |
| 94 | + "subscriptionId", self.ctx.subscription_id, |
| 95 | + required=True, |
| 96 | + ), |
| 97 | + } |
| 98 | + return parameters |
| 99 | + |
| 100 | + @property |
| 101 | + def query_parameters(self): |
| 102 | + parameters = { |
| 103 | + **self.serialize_query_param( |
| 104 | + "api-version", "2025-06-01", |
| 105 | + required=True, |
| 106 | + ), |
| 107 | + } |
| 108 | + return parameters |
| 109 | + |
| 110 | + @property |
| 111 | + def header_parameters(self): |
| 112 | + parameters = { |
| 113 | + **self.serialize_header_param( |
| 114 | + "Accept", "application/json", |
| 115 | + ), |
| 116 | + } |
| 117 | + return parameters |
| 118 | + |
| 119 | + def on_200(self, session): |
| 120 | + data = self.deserialize_http_content(session) |
| 121 | + self.ctx.set_var( |
| 122 | + "instance", |
| 123 | + data, |
| 124 | + schema_builder=self._build_schema_on_200 |
| 125 | + ) |
| 126 | + |
| 127 | + _schema_on_200 = None |
| 128 | + |
| 129 | + @classmethod |
| 130 | + def _build_schema_on_200(cls): |
| 131 | + if cls._schema_on_200 is not None: |
| 132 | + return cls._schema_on_200 |
| 133 | + |
| 134 | + cls._schema_on_200 = AAZObjectType() |
| 135 | + |
| 136 | + _schema_on_200 = cls._schema_on_200 |
| 137 | + _schema_on_200.properties = AAZObjectType() |
| 138 | + |
| 139 | + properties = cls._schema_on_200.properties |
| 140 | + properties.billed_azure_subscription_id = AAZStrType( |
| 141 | + serialized_name="billedAzureSubscriptionId", |
| 142 | + ) |
| 143 | + properties.elastic_organization_id = AAZStrType( |
| 144 | + serialized_name="elasticOrganizationId", |
| 145 | + ) |
| 146 | + properties.elastic_organization_name = AAZStrType( |
| 147 | + serialized_name="elasticOrganizationName", |
| 148 | + ) |
| 149 | + properties.marketplace_saas_info = AAZObjectType( |
| 150 | + serialized_name="marketplaceSaasInfo", |
| 151 | + flags={"read_only": True}, |
| 152 | + ) |
| 153 | + |
| 154 | + marketplace_saas_info = cls._schema_on_200.properties.marketplace_saas_info |
| 155 | + marketplace_saas_info.billed_azure_subscription_id = AAZStrType( |
| 156 | + serialized_name="billedAzureSubscriptionId", |
| 157 | + ) |
| 158 | + marketplace_saas_info.marketplace_name = AAZStrType( |
| 159 | + serialized_name="marketplaceName", |
| 160 | + ) |
| 161 | + marketplace_saas_info.marketplace_resource_id = AAZStrType( |
| 162 | + serialized_name="marketplaceResourceId", |
| 163 | + ) |
| 164 | + marketplace_saas_info.marketplace_status = AAZStrType( |
| 165 | + serialized_name="marketplaceStatus", |
| 166 | + ) |
| 167 | + marketplace_saas_info.marketplace_subscription = AAZObjectType( |
| 168 | + serialized_name="marketplaceSubscription", |
| 169 | + ) |
| 170 | + marketplace_saas_info.subscribed = AAZBoolType() |
| 171 | + |
| 172 | + marketplace_subscription = cls._schema_on_200.properties.marketplace_saas_info.marketplace_subscription |
| 173 | + marketplace_subscription.id = AAZStrType() |
| 174 | + marketplace_subscription.offer_id = AAZStrType( |
| 175 | + serialized_name="offerId", |
| 176 | + ) |
| 177 | + marketplace_subscription.publisher_id = AAZStrType( |
| 178 | + serialized_name="publisherId", |
| 179 | + ) |
| 180 | + |
| 181 | + return cls._schema_on_200 |
| 182 | + |
| 183 | + |
| 184 | +class _GetElasticOrganizationToAzureSubscriptionMappingHelper: |
| 185 | + """Helper class for GetElasticOrganizationToAzureSubscriptionMapping""" |
| 186 | + |
| 187 | + |
| 188 | +__all__ = ["GetElasticOrganizationToAzureSubscriptionMapping"] |
0 commit comments