diff --git a/sdk/nginx/azure-mgmt-nginx/CHANGELOG.md b/sdk/nginx/azure-mgmt-nginx/CHANGELOG.md index a8be3c65efde..7cb5eb9ee6cf 100644 --- a/sdk/nginx/azure-mgmt-nginx/CHANGELOG.md +++ b/sdk/nginx/azure-mgmt-nginx/CHANGELOG.md @@ -1,5 +1,60 @@ # Release History +## 3.1.0b3 (2025-11-10) + +### Features Added + + - Model `NginxManagementClient` added parameter `cloud_setting` in method `__init__` + - Client `NginxManagementClient` added operation group `default_waf_policy` + - Client `NginxManagementClient` added operation group `waf_policy` + - Model `AnalysisCreate` added property `root_file` + - Model `AnalysisCreate` added property `files` + - Model `AnalysisCreate` added property `protected_files` + - Model `AnalysisCreate` added property `package` + - Model `AnalysisResult` added property `errors` + - Model `AnalysisResult` added property `diagnostics` + - Model `NginxDeploymentApiKeyRequest` added property `system_data` + - Model `NginxDeploymentApiKeyResponse` added property `system_data` + - Model `NginxDeploymentProperties` added property `web_application_firewall_settings` + - Model `NginxDeploymentProperties` added property `web_application_firewall_status` + - Model `NginxDeploymentUpdateProperties` added property `web_application_firewall_settings` + - Model `ScaleProfile` added property `min` + - Model `ScaleProfile` added property `max` + - Model `WebApplicationFirewallStatus` added property `waf_release` + - Added enum `ActionType` + - Added model `NginxDeploymentDefaultWafPolicyListResponse` + - Added model `NginxDeploymentDefaultWafPolicyProperties` + - Added model `NginxDeploymentWafPolicy` + - Added model `NginxDeploymentWafPolicyApplyingStatus` + - Added enum `NginxDeploymentWafPolicyApplyingStatusCode` + - Added model `NginxDeploymentWafPolicyCompilingStatus` + - Added enum `NginxDeploymentWafPolicyCompilingStatusCode` + - Added model `NginxDeploymentWafPolicyListResponse` + - Added model `NginxDeploymentWafPolicyMetadata` + - Added model `NginxDeploymentWafPolicyMetadataProperties` + - Added model `NginxDeploymentWafPolicyProperties` + - Added model `Operation` + - Added enum `Origin` + - Added model `ProxyResource` + - Added model `Resource` + - Added model `TrackedResource` + - Added operation group `DefaultWafPolicyOperations` + - Added operation group `WafPolicyOperations` + +### Breaking Changes + + - Model `AnalysisCreate` deleted or renamed its instance variable `config` + - Model `AnalysisResult` deleted or renamed its instance variable `data` + - Model `NginxDeploymentProperties` deleted or renamed its instance variable `nginx_app_protect` + - Model `NginxDeploymentUpdateProperties` deleted or renamed its instance variable `nginx_app_protect` + - Model `ScaleProfile` deleted or renamed its instance variable `capacity` + - Deleted or renamed model `AnalysisCreateConfig` + - Deleted or renamed model `AnalysisResultData` + - Deleted or renamed model `NginxDeploymentPropertiesNginxAppProtect` + - Deleted or renamed model `NginxDeploymentUpdatePropertiesNginxAppProtect` + - Deleted or renamed model `OperationResult` + - Deleted or renamed model `ScaleProfileCapacity` + ## 3.1.0b2 (2025-02-23) ### Features Added diff --git a/sdk/nginx/azure-mgmt-nginx/MANIFEST.in b/sdk/nginx/azure-mgmt-nginx/MANIFEST.in index 0a86756feb30..a9566bdfe849 100644 --- a/sdk/nginx/azure-mgmt-nginx/MANIFEST.in +++ b/sdk/nginx/azure-mgmt-nginx/MANIFEST.in @@ -1,8 +1,7 @@ -include _meta.json -recursive-include tests *.py *.json -recursive-include samples *.py *.md include *.md -include azure/__init__.py -include azure/mgmt/__init__.py include LICENSE include azure/mgmt/nginx/py.typed +recursive-include tests *.py +recursive-include samples *.py *.md +include azure/__init__.py +include azure/mgmt/__init__.py diff --git a/sdk/nginx/azure-mgmt-nginx/README.md b/sdk/nginx/azure-mgmt-nginx/README.md index 2c66b7bf631c..77365a5e04a4 100644 --- a/sdk/nginx/azure-mgmt-nginx/README.md +++ b/sdk/nginx/azure-mgmt-nginx/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Nginx Management Client Library. -This package has been tested with Python 3.8+. +This package has been tested with Python 3.9+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.8+ is required to use this package. +- Python 3.9+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package @@ -24,7 +24,7 @@ pip install azure-identity ### Authentication -By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configure of following environment variables. +By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configuration of the following environment variables. - `AZURE_CLIENT_ID` for Azure client ID. - `AZURE_TENANT_ID` for Azure tenant ID. diff --git a/sdk/nginx/azure-mgmt-nginx/_meta.json b/sdk/nginx/azure-mgmt-nginx/_meta.json deleted file mode 100644 index db32155549ec..000000000000 --- a/sdk/nginx/azure-mgmt-nginx/_meta.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "commit": "198ffdb2b788b49be283a388ad9735b0cfad1be1", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.10.2", - "use": [ - "@autorest/python@6.27.4", - "@autorest/modelerfour@4.27.0" - ], - "autorest_command": "autorest specification/nginx/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.27.4 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", - "readme": "specification/nginx/resource-manager/readme.md" -} \ No newline at end of file diff --git a/sdk/nginx/azure-mgmt-nginx/_metadata.json b/sdk/nginx/azure-mgmt-nginx/_metadata.json new file mode 100644 index 000000000000..81771c2c0530 --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/_metadata.json @@ -0,0 +1,14 @@ +{ + "apiVersion": "2025-03-01-preview", + "commit": "d8f039ebd965e40471a082c547b103dd5dc9a33b", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "typespec_src": "specification/nginx/Nginx.Management", + "emitterVersion": "0.52.1", + "autorest": "3.10.2", + "use": [ + "@autorest/python@6.41.3", + "@autorest/modelerfour@4.27.0" + ], + "autorest_command": "autorest specification/nginx/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --package-mode=azure-mgmt --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.41.3 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", + "readme": "specification/nginx/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/nginx/azure-mgmt-nginx/apiview-properties.json b/sdk/nginx/azure-mgmt-nginx/apiview-properties.json new file mode 100644 index 000000000000..655e384bc9b2 --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/apiview-properties.json @@ -0,0 +1,129 @@ +{ + "CrossLanguagePackageId": null, + "CrossLanguageDefinitionId": { + "azure.mgmt.nginx.models.AnalysisCreate": null, + "azure.mgmt.nginx.models.AnalysisDiagnostic": null, + "azure.mgmt.nginx.models.AnalysisResult": null, + "azure.mgmt.nginx.models.AutoUpgradeProfile": null, + "azure.mgmt.nginx.models.DiagnosticItem": null, + "azure.mgmt.nginx.models.ErrorAdditionalInfo": null, + "azure.mgmt.nginx.models.ErrorDetail": null, + "azure.mgmt.nginx.models.ErrorResponse": null, + "azure.mgmt.nginx.models.IdentityProperties": null, + "azure.mgmt.nginx.models.Resource": null, + "azure.mgmt.nginx.models.ProxyResource": null, + "azure.mgmt.nginx.models.NginxCertificate": null, + "azure.mgmt.nginx.models.NginxCertificateErrorResponseBody": null, + "azure.mgmt.nginx.models.NginxCertificateListResponse": null, + "azure.mgmt.nginx.models.NginxCertificateProperties": null, + "azure.mgmt.nginx.models.NginxConfigurationFile": null, + "azure.mgmt.nginx.models.NginxConfigurationListResponse": null, + "azure.mgmt.nginx.models.NginxConfigurationPackage": null, + "azure.mgmt.nginx.models.NginxConfigurationProtectedFileRequest": null, + "azure.mgmt.nginx.models.NginxConfigurationProtectedFileResponse": null, + "azure.mgmt.nginx.models.NginxConfigurationRequest": null, + "azure.mgmt.nginx.models.NginxConfigurationRequestProperties": null, + "azure.mgmt.nginx.models.NginxConfigurationResponse": null, + "azure.mgmt.nginx.models.NginxConfigurationResponseProperties": null, + "azure.mgmt.nginx.models.TrackedResource": null, + "azure.mgmt.nginx.models.NginxDeployment": null, + "azure.mgmt.nginx.models.NginxDeploymentApiKeyListResponse": null, + "azure.mgmt.nginx.models.NginxDeploymentApiKeyRequest": null, + "azure.mgmt.nginx.models.NginxDeploymentApiKeyRequestProperties": null, + "azure.mgmt.nginx.models.NginxDeploymentApiKeyResponse": null, + "azure.mgmt.nginx.models.NginxDeploymentApiKeyResponseProperties": null, + "azure.mgmt.nginx.models.NginxDeploymentDefaultWafPolicyListResponse": null, + "azure.mgmt.nginx.models.NginxDeploymentDefaultWafPolicyProperties": null, + "azure.mgmt.nginx.models.NginxDeploymentListResponse": null, + "azure.mgmt.nginx.models.NginxDeploymentProperties": null, + "azure.mgmt.nginx.models.NginxDeploymentScalingProperties": null, + "azure.mgmt.nginx.models.NginxDeploymentUpdateParameters": null, + "azure.mgmt.nginx.models.NginxDeploymentUpdateProperties": null, + "azure.mgmt.nginx.models.NginxDeploymentUserProfile": null, + "azure.mgmt.nginx.models.NginxDeploymentWafPolicy": null, + "azure.mgmt.nginx.models.NginxDeploymentWafPolicyApplyingStatus": null, + "azure.mgmt.nginx.models.NginxDeploymentWafPolicyCompilingStatus": null, + "azure.mgmt.nginx.models.NginxDeploymentWafPolicyListResponse": null, + "azure.mgmt.nginx.models.NginxDeploymentWafPolicyMetadata": null, + "azure.mgmt.nginx.models.NginxDeploymentWafPolicyMetadataProperties": null, + "azure.mgmt.nginx.models.NginxDeploymentWafPolicyProperties": null, + "azure.mgmt.nginx.models.NginxFrontendIPConfiguration": null, + "azure.mgmt.nginx.models.NginxLogging": null, + "azure.mgmt.nginx.models.NginxNetworkInterfaceConfiguration": null, + "azure.mgmt.nginx.models.NginxNetworkProfile": null, + "azure.mgmt.nginx.models.NginxPrivateIPAddress": null, + "azure.mgmt.nginx.models.NginxPublicIPAddress": null, + "azure.mgmt.nginx.models.NginxStorageAccount": null, + "azure.mgmt.nginx.models.Operation": null, + "azure.mgmt.nginx.models.OperationDisplay": null, + "azure.mgmt.nginx.models.OperationListResult": null, + "azure.mgmt.nginx.models.ResourceSku": null, + "azure.mgmt.nginx.models.ScaleProfile": null, + "azure.mgmt.nginx.models.SystemData": null, + "azure.mgmt.nginx.models.UserIdentityProperties": null, + "azure.mgmt.nginx.models.WebApplicationFirewallComponentVersions": null, + "azure.mgmt.nginx.models.WebApplicationFirewallPackage": null, + "azure.mgmt.nginx.models.WebApplicationFirewallSettings": null, + "azure.mgmt.nginx.models.WebApplicationFirewallStatus": null, + "azure.mgmt.nginx.models.Origin": null, + "azure.mgmt.nginx.models.ActionType": null, + "azure.mgmt.nginx.models.NginxPrivateIPAllocationMethod": null, + "azure.mgmt.nginx.models.CreatedByType": null, + "azure.mgmt.nginx.models.ProvisioningState": null, + "azure.mgmt.nginx.models.ActivationState": null, + "azure.mgmt.nginx.models.IdentityType": null, + "azure.mgmt.nginx.models.Level": null, + "azure.mgmt.nginx.models.NginxDeploymentWafPolicyCompilingStatusCode": null, + "azure.mgmt.nginx.models.NginxDeploymentWafPolicyApplyingStatusCode": null, + "azure.mgmt.nginx.operations.Operations.list": null, + "azure.mgmt.nginx.aio.operations.Operations.list": null, + "azure.mgmt.nginx.operations.DeploymentsOperations.list": null, + "azure.mgmt.nginx.aio.operations.DeploymentsOperations.list": null, + "azure.mgmt.nginx.operations.DeploymentsOperations.list_by_resource_group": null, + "azure.mgmt.nginx.aio.operations.DeploymentsOperations.list_by_resource_group": null, + "azure.mgmt.nginx.operations.DeploymentsOperations.get": null, + "azure.mgmt.nginx.aio.operations.DeploymentsOperations.get": null, + "azure.mgmt.nginx.operations.DeploymentsOperations.begin_create_or_update": null, + "azure.mgmt.nginx.aio.operations.DeploymentsOperations.begin_create_or_update": null, + "azure.mgmt.nginx.operations.DeploymentsOperations.begin_update": null, + "azure.mgmt.nginx.aio.operations.DeploymentsOperations.begin_update": null, + "azure.mgmt.nginx.operations.DeploymentsOperations.begin_delete": null, + "azure.mgmt.nginx.aio.operations.DeploymentsOperations.begin_delete": null, + "azure.mgmt.nginx.operations.ApiKeysOperations.list": null, + "azure.mgmt.nginx.aio.operations.ApiKeysOperations.list": null, + "azure.mgmt.nginx.operations.ApiKeysOperations.get": null, + "azure.mgmt.nginx.aio.operations.ApiKeysOperations.get": null, + "azure.mgmt.nginx.operations.ApiKeysOperations.create_or_update": null, + "azure.mgmt.nginx.aio.operations.ApiKeysOperations.create_or_update": null, + "azure.mgmt.nginx.operations.ApiKeysOperations.delete": null, + "azure.mgmt.nginx.aio.operations.ApiKeysOperations.delete": null, + "azure.mgmt.nginx.operations.CertificatesOperations.list": null, + "azure.mgmt.nginx.aio.operations.CertificatesOperations.list": null, + "azure.mgmt.nginx.operations.CertificatesOperations.get": null, + "azure.mgmt.nginx.aio.operations.CertificatesOperations.get": null, + "azure.mgmt.nginx.operations.CertificatesOperations.begin_create_or_update": null, + "azure.mgmt.nginx.aio.operations.CertificatesOperations.begin_create_or_update": null, + "azure.mgmt.nginx.operations.CertificatesOperations.begin_delete": null, + "azure.mgmt.nginx.aio.operations.CertificatesOperations.begin_delete": null, + "azure.mgmt.nginx.operations.ConfigurationsOperations.list": null, + "azure.mgmt.nginx.aio.operations.ConfigurationsOperations.list": null, + "azure.mgmt.nginx.operations.ConfigurationsOperations.get": null, + "azure.mgmt.nginx.aio.operations.ConfigurationsOperations.get": null, + "azure.mgmt.nginx.operations.ConfigurationsOperations.begin_create_or_update": null, + "azure.mgmt.nginx.aio.operations.ConfigurationsOperations.begin_create_or_update": null, + "azure.mgmt.nginx.operations.ConfigurationsOperations.begin_delete": null, + "azure.mgmt.nginx.aio.operations.ConfigurationsOperations.begin_delete": null, + "azure.mgmt.nginx.operations.ConfigurationsOperations.analysis": null, + "azure.mgmt.nginx.aio.operations.ConfigurationsOperations.analysis": null, + "azure.mgmt.nginx.operations.DefaultWafPolicyOperations.list": null, + "azure.mgmt.nginx.aio.operations.DefaultWafPolicyOperations.list": null, + "azure.mgmt.nginx.operations.WafPolicyOperations.list": null, + "azure.mgmt.nginx.aio.operations.WafPolicyOperations.list": null, + "azure.mgmt.nginx.operations.WafPolicyOperations.get": null, + "azure.mgmt.nginx.aio.operations.WafPolicyOperations.get": null, + "azure.mgmt.nginx.operations.WafPolicyOperations.begin_create": null, + "azure.mgmt.nginx.aio.operations.WafPolicyOperations.begin_create": null, + "azure.mgmt.nginx.operations.WafPolicyOperations.begin_delete": null, + "azure.mgmt.nginx.aio.operations.WafPolicyOperations.begin_delete": null + } +} \ No newline at end of file diff --git a/sdk/nginx/azure-mgmt-nginx/azure/__init__.py b/sdk/nginx/azure-mgmt-nginx/azure/__init__.py index 8db66d3d0f0f..d55ccad1f573 100644 --- a/sdk/nginx/azure-mgmt-nginx/azure/__init__.py +++ b/sdk/nginx/azure-mgmt-nginx/azure/__init__.py @@ -1 +1 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/__init__.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/__init__.py index 8db66d3d0f0f..d55ccad1f573 100644 --- a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/__init__.py +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/__init__.py @@ -1 +1 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_configuration.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_configuration.py index 56f0a070f8e5..b84e58cb0e25 100644 --- a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_configuration.py +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_configuration.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy @@ -14,6 +14,7 @@ from ._version import VERSION if TYPE_CHECKING: + from azure.core import AzureClouds from azure.core.credentials import TokenCredential @@ -27,13 +28,22 @@ class NginxManagementClientConfiguration: # pylint: disable=too-many-instance-a :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2024-11-01-preview". Note that overriding + :param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :type cloud_setting: ~azure.core.AzureClouds + :keyword api_version: Api Version. Default value is "2025-03-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2024-11-01-preview") + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + cloud_setting: Optional["AzureClouds"] = None, + **kwargs: Any + ) -> None: + api_version: str = kwargs.pop("api_version", "2025-03-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -42,6 +52,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.credential = credential self.subscription_id = subscription_id + self.cloud_setting = cloud_setting self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-nginx/{}".format(VERSION)) diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_nginx_management_client.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_nginx_management_client.py index bad67fdda2bf..3fc1bb390d98 100644 --- a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_nginx_management_client.py +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_nginx_management_client.py @@ -7,49 +7,61 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING, cast from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse +from azure.core.settings import settings from azure.mgmt.core import ARMPipelineClient from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy +from azure.mgmt.core.tools import get_arm_endpoints from . import models as _models from ._configuration import NginxManagementClientConfiguration -from ._serialization import Deserializer, Serializer +from ._utils.serialization import Deserializer, Serializer from .operations import ( ApiKeysOperations, CertificatesOperations, ConfigurationsOperations, + DefaultWafPolicyOperations, DeploymentsOperations, Operations, + WafPolicyOperations, ) if TYPE_CHECKING: + from azure.core import AzureClouds from azure.core.credentials import TokenCredential -class NginxManagementClient: +class NginxManagementClient: # pylint: disable=too-many-instance-attributes """NginxManagementClient. + :ivar operations: Operations operations + :vartype operations: azure.mgmt.nginx.operations.Operations + :ivar deployments: DeploymentsOperations operations + :vartype deployments: azure.mgmt.nginx.operations.DeploymentsOperations :ivar api_keys: ApiKeysOperations operations :vartype api_keys: azure.mgmt.nginx.operations.ApiKeysOperations :ivar certificates: CertificatesOperations operations :vartype certificates: azure.mgmt.nginx.operations.CertificatesOperations :ivar configurations: ConfigurationsOperations operations :vartype configurations: azure.mgmt.nginx.operations.ConfigurationsOperations - :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.nginx.operations.DeploymentsOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.nginx.operations.Operations + :ivar default_waf_policy: DefaultWafPolicyOperations operations + :vartype default_waf_policy: azure.mgmt.nginx.operations.DefaultWafPolicyOperations + :ivar waf_policy: WafPolicyOperations operations + :vartype waf_policy: azure.mgmt.nginx.operations.WafPolicyOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". + :param base_url: Service URL. Default value is None. :type base_url: str - :keyword api_version: Api Version. Default value is "2024-11-01-preview". Note that overriding + :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :paramtype cloud_setting: ~azure.core.AzureClouds + :keyword api_version: Api Version. Default value is "2025-03-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -60,12 +72,24 @@ def __init__( self, credential: "TokenCredential", subscription_id: str, - base_url: str = "https://management.azure.com", + base_url: Optional[str] = None, + *, + cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: + _cloud = cloud_setting or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + base_url = _endpoints["resource_manager"] + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) self._config = NginxManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs + credential=credential, + subscription_id=subscription_id, + cloud_setting=cloud_setting, + credential_scopes=credential_scopes, + **kwargs ) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -84,17 +108,21 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) self.api_keys = ApiKeysOperations(self._client, self._config, self._serialize, self._deserialize) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) self.configurations = ConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.default_waf_policy = DefaultWafPolicyOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.waf_policy = WafPolicyOperations(self._client, self._config, self._serialize, self._deserialize) def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_patch.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_patch.py index 17dbc073e01b..87676c65a8f0 100644 --- a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_patch.py +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_patch.py @@ -1,32 +1,21 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------- +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level -# This file is used for handwritten extensions to the generated code. Example: -# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_utils/__init__.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_utils/__init__.py new file mode 100644 index 000000000000..0af9b28f6607 --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_utils/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_serialization.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_utils/serialization.py similarity index 93% rename from sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_serialization.py rename to sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_utils/serialization.py index b24ab2885450..ff543ed937ff 100644 --- a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_serialization.py +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_utils/serialization.py @@ -1,28 +1,10 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# 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. # -------------------------------------------------------------------------- # pyright: reportUnnecessaryTypeIgnoreComment=false @@ -39,7 +21,6 @@ import sys import codecs from typing import ( - Dict, Any, cast, Optional, @@ -48,10 +29,7 @@ IO, Mapping, Callable, - TypeVar, MutableMapping, - Type, - List, ) try: @@ -61,13 +39,13 @@ import xml.etree.ElementTree as ET import isodate # type: ignore +from typing_extensions import Self from azure.core.exceptions import DeserializationError, SerializationError from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") -ModelType = TypeVar("ModelType", bound="Model") JSON = MutableMapping[str, Any] @@ -185,73 +163,7 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], except NameError: _long_type = int - -class UTC(datetime.tzinfo): - """Time Zone info for handling UTC""" - - def utcoffset(self, dt): - """UTF offset for UTC is 0. - - :param datetime.datetime dt: The datetime - :returns: The offset - :rtype: datetime.timedelta - """ - return datetime.timedelta(0) - - def tzname(self, dt): - """Timestamp representation. - - :param datetime.datetime dt: The datetime - :returns: The timestamp representation - :rtype: str - """ - return "Z" - - def dst(self, dt): - """No daylight saving for UTC. - - :param datetime.datetime dt: The datetime - :returns: The daylight saving time - :rtype: datetime.timedelta - """ - return datetime.timedelta(hours=1) - - -try: - from datetime import timezone as _FixedOffset # type: ignore -except ImportError: # Python 2.7 - - class _FixedOffset(datetime.tzinfo): # type: ignore - """Fixed offset in minutes east from UTC. - Copy/pasted from Python doc - :param datetime.timedelta offset: offset in timedelta format - """ - - def __init__(self, offset) -> None: - self.__offset = offset - - def utcoffset(self, dt): - return self.__offset - - def tzname(self, dt): - return str(self.__offset.total_seconds() / 3600) - - def __repr__(self): - return "".format(self.tzname(None)) - - def dst(self, dt): - return datetime.timedelta(0) - - def __getinitargs__(self): - return (self.__offset,) - - -try: - from datetime import timezone - - TZ_UTC = timezone.utc -except ImportError: - TZ_UTC = UTC() # type: ignore +TZ_UTC = datetime.timezone.utc _FLATTEN = re.compile(r"(? None: - self.additional_properties: Optional[Dict[str, Any]] = {} + self.additional_properties: Optional[dict[str, Any]] = {} for k in kwargs: # pylint: disable=consider-using-dict-items if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) @@ -397,7 +309,7 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: def as_dict( self, keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + key_transformer: Callable[[str, dict[str, Any], Any], Any] = attribute_transformer, **kwargs: Any ) -> JSON: """Return a dict that can be serialized using json.dump. @@ -450,25 +362,25 @@ def _infer_class_models(cls): return client_models @classmethod - def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = None) -> ModelType: + def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: """Parse a str using the RestAPI syntax and return a model. :param str data: A str using RestAPI structure. JSON by default. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong - :rtype: ModelType + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( - cls: Type[ModelType], + cls, data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + key_extractors: Optional[Callable[[str, dict[str, Any], Any], Any]] = None, content_type: Optional[str] = None, - ) -> ModelType: + ) -> Self: """Parse a dict using given key extractor return a model. By default consider key @@ -479,8 +391,8 @@ def from_dict( :param function key_extractors: A key extractor function. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong - :rtype: ModelType + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) deserializer.key_extractors = ( # type: ignore @@ -500,7 +412,7 @@ def _flatten_subtype(cls, key, objects): return {} result = dict(cls._subtype_map[key]) for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access + result |= objects[valuetype]._flatten_subtype(key, objects) # pylint: disable=protected-access return result @classmethod @@ -614,7 +526,7 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.dependencies: dict[str, type] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -626,7 +538,7 @@ def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, to :param object target_obj: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, dict - :raises: SerializationError if serialization fails. + :raises SerializationError: if serialization fails. :returns: The serialized data. """ key_transformer = kwargs.get("key_transformer", self.key_transformer) @@ -665,7 +577,7 @@ def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, to if attr_name == "additional_properties" and attr_desc["key"] == "": if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) + serialized |= target_obj.additional_properties continue try: @@ -736,8 +648,8 @@ def body(self, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: dict - :raises: SerializationError if serialization fails. - :raises: ValueError if data is None + :raises SerializationError: if serialization fails. + :raises ValueError: if data is None :returns: The serialized request body """ @@ -781,8 +693,8 @@ def url(self, name, data, data_type, **kwargs): :param str data_type: The type to be serialized from. :rtype: str :returns: The serialized URL path - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None """ try: output = self.serialize_data(data, data_type, **kwargs) @@ -805,8 +717,8 @@ def query(self, name, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, list - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None :returns: The serialized query parameter """ try: @@ -835,8 +747,8 @@ def header(self, name, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None :returns: The serialized header """ try: @@ -855,9 +767,9 @@ def serialize_data(self, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :raises: AttributeError if required data is None. - :raises: ValueError if data is None - :raises: SerializationError if serialization fails. + :raises AttributeError: if required data is None. + :raises ValueError: if data is None + :raises SerializationError: if serialization fails. :returns: The serialized data. :rtype: str, int, float, bool, dict, list """ @@ -875,7 +787,7 @@ def serialize_data(self, data, data_type, **kwargs): # If dependencies is empty, try with current data class # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) + enum_type = self.dependencies.get(data_type, cast(type, data.__class__)) if issubclass(enum_type, Enum): return Serializer.serialize_enum(data, enum_obj=enum_type) @@ -1192,7 +1104,7 @@ def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument :param Datetime attr: Object to be serialized. :rtype: str - :raises: TypeError if format invalid. + :raises TypeError: if format invalid. :return: serialized rfc """ try: @@ -1218,7 +1130,7 @@ def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument :param Datetime attr: Object to be serialized. :rtype: str - :raises: SerializationError if format invalid. + :raises SerializationError: if format invalid. :return: serialized iso """ if isinstance(attr, str): @@ -1251,7 +1163,7 @@ def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument :param Datetime attr: Object to be serialized. :rtype: int - :raises: SerializationError if format invalid + :raises SerializationError: if format invalid :return: serialied unix """ if isinstance(attr, int): @@ -1270,7 +1182,7 @@ def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argumen while "." in key: # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) + dict_keys = cast(list[str], _FLATTEN.split(key)) if len(dict_keys) == 1: key = _decode_attribute_map_key(dict_keys[0]) break @@ -1429,7 +1341,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) @@ -1472,7 +1384,7 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.dependencies: dict[str, type] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1488,7 +1400,7 @@ def __call__(self, target_obj, response_data, content_type=None): :param str target_obj: Target data type to deserialize to. :param requests.Response response_data: REST response object. :param str content_type: Swagger "produces" if available. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. :rtype: object """ @@ -1502,7 +1414,7 @@ def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return :param str target_obj: Target data type to deserialize to. :param object data: Object to deserialize. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. :rtype: object """ @@ -1717,7 +1629,7 @@ def deserialize_data(self, data, data_type): # pylint: disable=too-many-return- :param str data: The response string to be deserialized. :param str data_type: The type to deserialize to. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. :rtype: object """ @@ -1799,7 +1711,7 @@ def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return :param dict attr: Dictionary to be deserialized. :return: Deserialized object. :rtype: dict - :raises: TypeError if non-builtin datatype encountered. + :raises TypeError: if non-builtin datatype encountered. """ if attr is None: return None @@ -1845,7 +1757,7 @@ def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return :param str data_type: deserialization data type. :return: Deserialized basic type. :rtype: str, int, float or bool - :raises: TypeError if string format is not valid. + :raises TypeError: if string format is not valid. """ # If we're here, data is supposed to be a basic type. # If it's still an XML node, take the text @@ -1936,7 +1848,7 @@ def deserialize_bytearray(attr): :param str attr: response string to be deserialized. :return: Deserialized bytearray :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1949,7 +1861,7 @@ def deserialize_base64(attr): :param str attr: response string to be deserialized. :return: Deserialized base64 string :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1964,7 +1876,7 @@ def deserialize_decimal(attr): :param str attr: response string to be deserialized. :return: Deserialized decimal - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. :rtype: decimal """ if isinstance(attr, ET.Element): @@ -1982,7 +1894,7 @@ def deserialize_long(attr): :param str attr: response string to be deserialized. :return: Deserialized int :rtype: long or int - :raises: ValueError if string format invalid. + :raises ValueError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1995,7 +1907,7 @@ def deserialize_duration(attr): :param str attr: response string to be deserialized. :return: Deserialized duration :rtype: TimeDelta - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2013,7 +1925,7 @@ def deserialize_date(attr): :param str attr: response string to be deserialized. :return: Deserialized date :rtype: Date - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2029,7 +1941,7 @@ def deserialize_time(attr): :param str attr: response string to be deserialized. :return: Deserialized time :rtype: datetime.time - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2044,14 +1956,14 @@ def deserialize_rfc(attr): :param str attr: response string to be deserialized. :return: Deserialized RFC datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text try: parsed_date = email.utils.parsedate_tz(attr) # type: ignore date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) ) if not date_obj.tzinfo: date_obj = date_obj.astimezone(tz=TZ_UTC) @@ -2067,7 +1979,7 @@ def deserialize_iso(attr): :param str attr: response string to be deserialized. :return: Deserialized ISO datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2105,7 +2017,7 @@ def deserialize_unix(attr): :param int attr: Object to be serialized. :return: Deserialized datetime :rtype: Datetime - :raises: DeserializationError if format invalid + :raises DeserializationError: if format invalid """ if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_version.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_version.py index d5129bebc550..978d841f3d46 100644 --- a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_version.py +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/_version.py @@ -2,8 +2,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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.1.0b2" +VERSION = "3.1.0b3" diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/_configuration.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/_configuration.py index 4f3d3d8449a9..c37b2098d746 100644 --- a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/_configuration.py +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/_configuration.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy @@ -14,6 +14,7 @@ from .._version import VERSION if TYPE_CHECKING: + from azure.core import AzureClouds from azure.core.credentials_async import AsyncTokenCredential @@ -27,13 +28,22 @@ class NginxManagementClientConfiguration: # pylint: disable=too-many-instance-a :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2024-11-01-preview". Note that overriding + :param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :type cloud_setting: ~azure.core.AzureClouds + :keyword api_version: Api Version. Default value is "2025-03-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2024-11-01-preview") + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + cloud_setting: Optional["AzureClouds"] = None, + **kwargs: Any + ) -> None: + api_version: str = kwargs.pop("api_version", "2025-03-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -42,6 +52,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.credential = credential self.subscription_id = subscription_id + self.cloud_setting = cloud_setting self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-nginx/{}".format(VERSION)) diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/_nginx_management_client.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/_nginx_management_client.py index 059f95c1db19..5ed3e937ad29 100644 --- a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/_nginx_management_client.py +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/_nginx_management_client.py @@ -7,49 +7,61 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING +from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.settings import settings from azure.mgmt.core import AsyncARMPipelineClient from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy +from azure.mgmt.core.tools import get_arm_endpoints from .. import models as _models -from .._serialization import Deserializer, Serializer +from .._utils.serialization import Deserializer, Serializer from ._configuration import NginxManagementClientConfiguration from .operations import ( ApiKeysOperations, CertificatesOperations, ConfigurationsOperations, + DefaultWafPolicyOperations, DeploymentsOperations, Operations, + WafPolicyOperations, ) if TYPE_CHECKING: + from azure.core import AzureClouds from azure.core.credentials_async import AsyncTokenCredential -class NginxManagementClient: +class NginxManagementClient: # pylint: disable=too-many-instance-attributes """NginxManagementClient. + :ivar operations: Operations operations + :vartype operations: azure.mgmt.nginx.aio.operations.Operations + :ivar deployments: DeploymentsOperations operations + :vartype deployments: azure.mgmt.nginx.aio.operations.DeploymentsOperations :ivar api_keys: ApiKeysOperations operations :vartype api_keys: azure.mgmt.nginx.aio.operations.ApiKeysOperations :ivar certificates: CertificatesOperations operations :vartype certificates: azure.mgmt.nginx.aio.operations.CertificatesOperations :ivar configurations: ConfigurationsOperations operations :vartype configurations: azure.mgmt.nginx.aio.operations.ConfigurationsOperations - :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.nginx.aio.operations.DeploymentsOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.nginx.aio.operations.Operations + :ivar default_waf_policy: DefaultWafPolicyOperations operations + :vartype default_waf_policy: azure.mgmt.nginx.aio.operations.DefaultWafPolicyOperations + :ivar waf_policy: WafPolicyOperations operations + :vartype waf_policy: azure.mgmt.nginx.aio.operations.WafPolicyOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". + :param base_url: Service URL. Default value is None. :type base_url: str - :keyword api_version: Api Version. Default value is "2024-11-01-preview". Note that overriding + :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :paramtype cloud_setting: ~azure.core.AzureClouds + :keyword api_version: Api Version. Default value is "2025-03-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -60,12 +72,24 @@ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: str = "https://management.azure.com", + base_url: Optional[str] = None, + *, + cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: + _cloud = cloud_setting or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + base_url = _endpoints["resource_manager"] + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) self._config = NginxManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs + credential=credential, + subscription_id=subscription_id, + cloud_setting=cloud_setting, + credential_scopes=credential_scopes, + **kwargs ) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -84,17 +108,23 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( + base_url=cast(str, base_url), policies=_policies, **kwargs + ) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) self.api_keys = ApiKeysOperations(self._client, self._config, self._serialize, self._deserialize) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) self.configurations = ConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.default_waf_policy = DefaultWafPolicyOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.waf_policy = WafPolicyOperations(self._client, self._config, self._serialize, self._deserialize) def _send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/_patch.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/_patch.py index 17dbc073e01b..87676c65a8f0 100644 --- a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/_patch.py +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/_patch.py @@ -1,32 +1,21 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------- +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level -# This file is used for handwritten extensions to the generated code. Example: -# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/__init__.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/__init__.py index bf1dfbd4df3e..8896f281e12d 100644 --- a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/__init__.py +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/__init__.py @@ -12,22 +12,26 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import +from ._operations import Operations # type: ignore +from ._deployments_operations import DeploymentsOperations # type: ignore from ._api_keys_operations import ApiKeysOperations # type: ignore from ._certificates_operations import CertificatesOperations # type: ignore from ._configurations_operations import ConfigurationsOperations # type: ignore -from ._deployments_operations import DeploymentsOperations # type: ignore -from ._operations import Operations # type: ignore +from ._default_waf_policy_operations import DefaultWafPolicyOperations # type: ignore +from ._waf_policy_operations import WafPolicyOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ + "Operations", + "DeploymentsOperations", "ApiKeysOperations", "CertificatesOperations", "ConfigurationsOperations", - "DeploymentsOperations", - "Operations", + "DefaultWafPolicyOperations", + "WafPolicyOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_api_keys_operations.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_api_keys_operations.py index 70d285bb6b1b..3c6ec48ecaec 100644 --- a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_api_keys_operations.py +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_api_keys_operations.py @@ -5,11 +5,12 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, IO, Optional, TypeVar, Union, overload import urllib.parse +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -27,19 +28,18 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer from ...operations._api_keys_operations import ( build_create_or_update_request, build_delete_request, build_get_request, build_list_request, ) +from .._configuration import NginxManagementClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list class ApiKeysOperations: @@ -56,10 +56,157 @@ class ApiKeysOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: NginxManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.NginxDeploymentApiKeyResponse"]: + """List all API Keys of the given Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of targeted NGINX deployment. Required. + :type deployment_name: str + :return: An iterator like instance of either NginxDeploymentApiKeyResponse or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.nginx.models.NginxDeploymentApiKeyResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NginxDeploymentApiKeyListResponse] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("NginxDeploymentApiKeyListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, deployment_name: str, api_key_name: str, **kwargs: Any + ) -> _models.NginxDeploymentApiKeyResponse: + """Get the specified API Key of the given Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of targeted NGINX deployment. Required. + :type deployment_name: str + :param api_key_name: The resource name of the API key. Required. + :type api_key_name: str + :return: NginxDeploymentApiKeyResponse or the result of cls(response) + :rtype: ~azure.mgmt.nginx.models.NginxDeploymentApiKeyResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NginxDeploymentApiKeyResponse] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + api_key_name=api_key_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NginxDeploymentApiKeyResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @overload async def create_or_update( @@ -75,9 +222,6 @@ async def create_or_update( """Create or update an API Key for the Nginx deployment in order to access the dataplane API endpoint. - Create or update an API Key for the Nginx deployment in order to access the dataplane API - endpoint. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -110,9 +254,6 @@ async def create_or_update( """Create or update an API Key for the Nginx deployment in order to access the dataplane API endpoint. - Create or update an API Key for the Nginx deployment in order to access the dataplane API - endpoint. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -143,9 +284,6 @@ async def create_or_update( """Create or update an API Key for the Nginx deployment in order to access the dataplane API endpoint. - Create or update an API Key for the Nginx deployment in order to access the dataplane API - endpoint. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -174,9 +312,10 @@ async def create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None cls: ClsType[_models.NginxDeploymentApiKeyResponse] = kwargs.pop("cls", None) - content_type = content_type or "application/json" + content_type = content_type or "application/json" if body else None _json = None _content = None if isinstance(body, (IOBase, bytes)): @@ -224,8 +363,6 @@ async def create_or_update( async def delete(self, resource_group_name: str, deployment_name: str, api_key_name: str, **kwargs: Any) -> None: """Delete API key for Nginx deployment. - Delete API key for Nginx deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -276,154 +413,3 @@ async def delete(self, resource_group_name: str, deployment_name: str, api_key_n if cls: return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def get( - self, resource_group_name: str, deployment_name: str, api_key_name: str, **kwargs: Any - ) -> _models.NginxDeploymentApiKeyResponse: - """Get the specified API Key of the given Nginx deployment. - - Get the specified API Key of the given Nginx deployment. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param deployment_name: The name of targeted NGINX deployment. Required. - :type deployment_name: str - :param api_key_name: The resource name of the API key. Required. - :type api_key_name: str - :return: NginxDeploymentApiKeyResponse or the result of cls(response) - :rtype: ~azure.mgmt.nginx.models.NginxDeploymentApiKeyResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.NginxDeploymentApiKeyResponse] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - api_key_name=api_key_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("NginxDeploymentApiKeyResponse", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, deployment_name: str, **kwargs: Any - ) -> AsyncIterable["_models.NginxDeploymentApiKeyResponse"]: - """List all API Keys of the given Nginx deployment. - - List all API Keys of the given Nginx deployment. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param deployment_name: The name of targeted NGINX deployment. Required. - :type deployment_name: str - :return: An iterator like instance of either NginxDeploymentApiKeyResponse or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.nginx.models.NginxDeploymentApiKeyResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.NginxDeploymentApiKeyListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("NginxDeploymentApiKeyListResponse", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_certificates_operations.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_certificates_operations.py index 5314cc4dac6f..e356e003216b 100644 --- a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_certificates_operations.py +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_certificates_operations.py @@ -5,11 +5,12 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload import urllib.parse +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -31,19 +32,18 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer from ...operations._certificates_operations import ( build_create_or_update_request, build_delete_request, build_get_request, build_list_request, ) +from .._configuration import NginxManagementClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list class CertificatesOperations: @@ -60,10 +60,94 @@ class CertificatesOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: NginxManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.NginxCertificate"]: + """List all certificates of given NGINX deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of targeted NGINX deployment. Required. + :type deployment_name: str + :return: An iterator like instance of either NginxCertificate or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.nginx.models.NginxCertificate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NginxCertificateListResponse] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("NginxCertificateListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) @distributed_trace_async async def get( @@ -71,8 +155,6 @@ async def get( ) -> _models.NginxCertificate: """Get a certificate of given NGINX deployment. - Get a certificate of given NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -149,9 +231,10 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" + content_type = content_type or "application/json" if body else None _json = None _content = None if isinstance(body, (IOBase, bytes)): @@ -193,10 +276,17 @@ async def _create_or_update_initial( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -213,8 +303,6 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.NginxCertificate]: """Create or update the NGINX certificates for given NGINX deployment. - Create or update the NGINX certificates for given NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -246,8 +334,6 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.NginxCertificate]: """Create or update the NGINX certificates for given NGINX deployment. - Create or update the NGINX certificates for given NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -277,8 +363,6 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.NginxCertificate]: """Create or update the NGINX certificates for given NGINX deployment. - Create or update the NGINX certificates for given NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -299,6 +383,7 @@ async def begin_create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None cls: ClsType[_models.NginxCertificate] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -381,7 +466,7 @@ async def _delete_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [202, 204]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -390,10 +475,15 @@ async def _delete_initial( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -403,8 +493,6 @@ async def begin_delete( ) -> AsyncLROPoller[None]: """Deletes a certificate from the NGINX deployment. - Deletes a certificate from the NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -443,7 +531,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -456,89 +546,3 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- deserialization_callback=get_long_running_output, ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, deployment_name: str, **kwargs: Any - ) -> AsyncIterable["_models.NginxCertificate"]: - """List all certificates of given NGINX deployment. - - List all certificates of given NGINX deployment. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param deployment_name: The name of targeted NGINX deployment. Required. - :type deployment_name: str - :return: An iterator like instance of either NginxCertificate or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.nginx.models.NginxCertificate] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.NginxCertificateListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("NginxCertificateListResponse", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_configurations_operations.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_configurations_operations.py index d5422b33ca06..ae26a4f49b72 100644 --- a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_configurations_operations.py +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_configurations_operations.py @@ -5,11 +5,12 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload import urllib.parse +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -31,6 +32,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer from ...operations._configurations_operations import ( build_analysis_request, build_create_or_update_request, @@ -38,13 +40,11 @@ build_get_request, build_list_request, ) +from .._configuration import NginxManagementClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list class ConfigurationsOperations: @@ -61,19 +61,17 @@ class ConfigurationsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: NginxManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, resource_group_name: str, deployment_name: str, **kwargs: Any - ) -> AsyncIterable["_models.NginxConfigurationResponse"]: + ) -> AsyncItemPaged["_models.NginxConfigurationResponse"]: """List the NGINX configuration of given NGINX deployment. - List the NGINX configuration of given NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -160,8 +158,6 @@ async def get( ) -> _models.NginxConfigurationResponse: """Get the NGINX configuration of given NGINX deployment. - Get the NGINX configuration of given NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -239,9 +235,10 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" + content_type = content_type or "application/json" if body else None _json = None _content = None if isinstance(body, (IOBase, bytes)): @@ -283,10 +280,17 @@ async def _create_or_update_initial( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -303,8 +307,6 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.NginxConfigurationResponse]: """Create or update the NGINX configuration for given NGINX deployment. - Create or update the NGINX configuration for given NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -337,8 +339,6 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.NginxConfigurationResponse]: """Create or update the NGINX configuration for given NGINX deployment. - Create or update the NGINX configuration for given NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -369,8 +369,6 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.NginxConfigurationResponse]: """Create or update the NGINX configuration for given NGINX deployment. - Create or update the NGINX configuration for given NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -392,6 +390,7 @@ async def begin_create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None cls: ClsType[_models.NginxConfigurationResponse] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -474,7 +473,7 @@ async def _delete_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [202, 204]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -483,10 +482,15 @@ async def _delete_initial( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -496,8 +500,6 @@ async def begin_delete( ) -> AsyncLROPoller[None]: """Reset the NGINX configuration of given NGINX deployment to default. - Reset the NGINX configuration of given NGINX deployment to default. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -537,7 +539,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -564,8 +568,6 @@ async def analysis( ) -> _models.AnalysisResult: """Analyze an NGINX configuration without applying it to the NGINXaaS deployment. - Analyze an NGINX configuration without applying it to the NGINXaaS deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -597,8 +599,6 @@ async def analysis( ) -> _models.AnalysisResult: """Analyze an NGINX configuration without applying it to the NGINXaaS deployment. - Analyze an NGINX configuration without applying it to the NGINXaaS deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -628,8 +628,6 @@ async def analysis( ) -> _models.AnalysisResult: """Analyze an NGINX configuration without applying it to the NGINXaaS deployment. - Analyze an NGINX configuration without applying it to the NGINXaaS deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -658,9 +656,10 @@ async def analysis( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None cls: ClsType[_models.AnalysisResult] = kwargs.pop("cls", None) - content_type = content_type or "application/json" + content_type = content_type or "application/json" if body else None _json = None _content = None if isinstance(body, (IOBase, bytes)): diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_default_waf_policy_operations.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_default_waf_policy_operations.py new file mode 100644 index 000000000000..a1d26b1dca1d --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_default_waf_policy_operations.py @@ -0,0 +1,111 @@ +# 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 collections.abc import MutableMapping +from typing import Any, Callable, Optional, TypeVar + +from azure.core import AsyncPipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._default_waf_policy_operations import build_list_request +from .._configuration import NginxManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list + + +class DefaultWafPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.nginx.aio.NginxManagementClient`'s + :attr:`default_waf_policy` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: NginxManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list( + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.NginxDeploymentDefaultWafPolicyListResponse: + """Get the Nginx Waf Policy of given Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of targeted NGINX deployment. Required. + :type deployment_name: str + :return: NginxDeploymentDefaultWafPolicyListResponse or the result of cls(response) + :rtype: ~azure.mgmt.nginx.models.NginxDeploymentDefaultWafPolicyListResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NginxDeploymentDefaultWafPolicyListResponse] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NginxDeploymentDefaultWafPolicyListResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_deployments_operations.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_deployments_operations.py index 7936214168b3..c8f670189e7f 100644 --- a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_deployments_operations.py +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_deployments_operations.py @@ -5,11 +5,12 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload import urllib.parse +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -31,6 +32,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer from ...operations._deployments_operations import ( build_create_or_update_request, build_delete_request, @@ -39,13 +41,11 @@ build_list_request, build_update_request, ) +from .._configuration import NginxManagementClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list class DeploymentsOperations: @@ -62,17 +62,171 @@ class DeploymentsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: NginxManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged["_models.NginxDeployment"]: + """List the NGINX deployments resources. + + :return: An iterator like instance of either NginxDeployment or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.nginx.models.NginxDeployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NginxDeploymentListResponse] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("NginxDeploymentListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.NginxDeployment"]: + """List all NGINX deployments under the specified resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either NginxDeployment or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.nginx.models.NginxDeployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NginxDeploymentListResponse] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("NginxDeploymentListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) @distributed_trace_async async def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.NginxDeployment: """Get the NGINX deployment. - Get the NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -145,9 +299,10 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" + content_type = content_type or "application/json" if body else None _json = None _content = None if isinstance(body, (IOBase, bytes)): @@ -188,10 +343,17 @@ async def _create_or_update_initial( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -207,14 +369,12 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.NginxDeployment]: """Create or update the NGINX deployment. - Create or update the NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param deployment_name: The name of targeted NGINX deployment. Required. :type deployment_name: str - :param body: Default value is None. + :param body: The Nginx deployment. Default value is None. :type body: ~azure.mgmt.nginx.models.NginxDeployment :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -237,14 +397,12 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.NginxDeployment]: """Create or update the NGINX deployment. - Create or update the NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param deployment_name: The name of targeted NGINX deployment. Required. :type deployment_name: str - :param body: Default value is None. + :param body: The Nginx deployment. Default value is None. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -265,14 +423,13 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.NginxDeployment]: """Create or update the NGINX deployment. - Create or update the NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param deployment_name: The name of targeted NGINX deployment. Required. :type deployment_name: str - :param body: Is either a NginxDeployment type or a IO[bytes] type. Default value is None. + :param body: The Nginx deployment. Is either a NginxDeployment type or a IO[bytes] type. + Default value is None. :type body: ~azure.mgmt.nginx.models.NginxDeployment or IO[bytes] :return: An instance of AsyncLROPoller that returns either NginxDeployment or the result of cls(response) @@ -284,6 +441,7 @@ async def begin_create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None cls: ClsType[_models.NginxDeployment] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -349,9 +507,10 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" + content_type = content_type or "application/json" if body else None _json = None _content = None if isinstance(body, (IOBase, bytes)): @@ -383,7 +542,7 @@ async def _update_initial( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200, 202]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -392,10 +551,17 @@ async def _update_initial( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -411,14 +577,12 @@ async def begin_update( ) -> AsyncLROPoller[_models.NginxDeployment]: """Update the NGINX deployment. - Update the NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param deployment_name: The name of targeted NGINX deployment. Required. :type deployment_name: str - :param body: Default value is None. + :param body: The Nginx deployment update parameters. Default value is None. :type body: ~azure.mgmt.nginx.models.NginxDeploymentUpdateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -441,14 +605,12 @@ async def begin_update( ) -> AsyncLROPoller[_models.NginxDeployment]: """Update the NGINX deployment. - Update the NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param deployment_name: The name of targeted NGINX deployment. Required. :type deployment_name: str - :param body: Default value is None. + :param body: The Nginx deployment update parameters. Default value is None. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -469,15 +631,13 @@ async def begin_update( ) -> AsyncLROPoller[_models.NginxDeployment]: """Update the NGINX deployment. - Update the NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param deployment_name: The name of targeted NGINX deployment. Required. :type deployment_name: str - :param body: Is either a NginxDeploymentUpdateParameters type or a IO[bytes] type. Default - value is None. + :param body: The Nginx deployment update parameters. Is either a + NginxDeploymentUpdateParameters type or a IO[bytes] type. Default value is None. :type body: ~azure.mgmt.nginx.models.NginxDeploymentUpdateParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either NginxDeployment or the result of cls(response) @@ -489,6 +649,7 @@ async def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None cls: ClsType[_models.NginxDeployment] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -515,7 +676,10 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -566,7 +730,7 @@ async def _delete_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [202, 204]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -575,10 +739,15 @@ async def _delete_initial( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -586,8 +755,6 @@ async def _delete_initial( async def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Delete the NGINX deployment resource. - Delete the NGINX deployment resource. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -623,7 +790,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -636,163 +805,3 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- deserialization_callback=get_long_running_output, ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.NginxDeployment"]: - """List the NGINX deployments resources. - - List the NGINX deployments resources. - - :return: An iterator like instance of either NginxDeployment or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.nginx.models.NginxDeployment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.NginxDeploymentListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("NginxDeploymentListResponse", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.NginxDeployment"]: - """List all NGINX deployments under the specified resource group. - - List all NGINX deployments under the specified resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :return: An iterator like instance of either NginxDeployment or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.nginx.models.NginxDeployment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.NginxDeploymentListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("NginxDeploymentListResponse", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_operations.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_operations.py index c945da5d2cef..901c40a2a40e 100644 --- a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_operations.py +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_operations.py @@ -5,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from collections.abc import MutableMapping +from typing import Any, Callable, Optional, TypeVar import urllib.parse +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -25,14 +26,13 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer from ...operations._operations import build_list_request +from .._configuration import NginxManagementClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list class Operations: @@ -49,19 +49,17 @@ class Operations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: NginxManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationResult"]: - """List all operations provided by Nginx.NginxPlus for the 2024-11-01-preview api version. + def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Operation"]: + """List the operations for the provider. - List all operations provided by Nginx.NginxPlus for the 2024-11-01-preview api version. - - :return: An iterator like instance of either OperationResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.nginx.models.OperationResult] + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.nginx.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_patch.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_patch.py index f7dd32510333..87676c65a8f0 100644 --- a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_patch.py +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_patch.py @@ -1,14 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_waf_policy_operations.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_waf_policy_operations.py new file mode 100644 index 000000000000..30561f43ab66 --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/aio/operations/_waf_policy_operations.py @@ -0,0 +1,551 @@ +# 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 collections.abc import MutableMapping +from io import IOBase +from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._waf_policy_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) +from .._configuration import NginxManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list + + +class WafPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.nginx.aio.NginxManagementClient`'s + :attr:`waf_policy` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: NginxManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.NginxDeploymentWafPolicyMetadata"]: + """List Waf Policies of given Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of targeted NGINX deployment. Required. + :type deployment_name: str + :return: An iterator like instance of either NginxDeploymentWafPolicyMetadata or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.nginx.models.NginxDeploymentWafPolicyMetadata] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NginxDeploymentWafPolicyListResponse] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("NginxDeploymentWafPolicyListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, deployment_name: str, waf_policy_name: str, **kwargs: Any + ) -> _models.NginxDeploymentWafPolicy: + """Get the Nginx Waf Policy of given Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of targeted NGINX deployment. Required. + :type deployment_name: str + :param waf_policy_name: The name of Waf Policy. Required. + :type waf_policy_name: str + :return: NginxDeploymentWafPolicy or the result of cls(response) + :rtype: ~azure.mgmt.nginx.models.NginxDeploymentWafPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NginxDeploymentWafPolicy] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + waf_policy_name=waf_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NginxDeploymentWafPolicy", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + deployment_name: str, + waf_policy_name: str, + body: Optional[Union[_models.NginxDeploymentWafPolicy, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if body else None + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "NginxDeploymentWafPolicy") + else: + _json = None + + _request = build_create_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + waf_policy_name=waf_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + deployment_name: str, + waf_policy_name: str, + body: Optional[_models.NginxDeploymentWafPolicy] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.NginxDeploymentWafPolicy]: + """Create or update the Nginx Waf Policy for given Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of targeted NGINX deployment. Required. + :type deployment_name: str + :param waf_policy_name: The name of Waf Policy. Required. + :type waf_policy_name: str + :param body: The Nginx Deployment Waf Policy. Default value is None. + :type body: ~azure.mgmt.nginx.models.NginxDeploymentWafPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either NginxDeploymentWafPolicy or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.nginx.models.NginxDeploymentWafPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + deployment_name: str, + waf_policy_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.NginxDeploymentWafPolicy]: + """Create or update the Nginx Waf Policy for given Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of targeted NGINX deployment. Required. + :type deployment_name: str + :param waf_policy_name: The name of Waf Policy. Required. + :type waf_policy_name: str + :param body: The Nginx Deployment Waf Policy. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either NginxDeploymentWafPolicy or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.nginx.models.NginxDeploymentWafPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + deployment_name: str, + waf_policy_name: str, + body: Optional[Union[_models.NginxDeploymentWafPolicy, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.NginxDeploymentWafPolicy]: + """Create or update the Nginx Waf Policy for given Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of targeted NGINX deployment. Required. + :type deployment_name: str + :param waf_policy_name: The name of Waf Policy. Required. + :type waf_policy_name: str + :param body: The Nginx Deployment Waf Policy. Is either a NginxDeploymentWafPolicy type or a + IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.nginx.models.NginxDeploymentWafPolicy or IO[bytes] + :return: An instance of AsyncLROPoller that returns either NginxDeploymentWafPolicy or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.nginx.models.NginxDeploymentWafPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None + cls: ClsType[_models.NginxDeploymentWafPolicy] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + waf_policy_name=waf_policy_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("NginxDeploymentWafPolicy", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.NginxDeploymentWafPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.NginxDeploymentWafPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, deployment_name: str, waf_policy_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + waf_policy_name=waf_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, deployment_name: str, waf_policy_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Reset the Nginx Waf Policy of given Nginx deployment to default. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of targeted NGINX deployment. Required. + :type deployment_name: str + :param waf_policy_name: The name of Waf Policy. Required. + :type waf_policy_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + waf_policy_name=waf_policy_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/models/__init__.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/models/__init__.py index 159f89a3eaec..cdadaaa31762 100644 --- a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/models/__init__.py +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/models/__init__.py @@ -15,10 +15,8 @@ from ._models_py3 import ( # type: ignore AnalysisCreate, - AnalysisCreateConfig, AnalysisDiagnostic, AnalysisResult, - AnalysisResultData, AutoUpgradeProfile, DiagnosticItem, ErrorAdditionalInfo, @@ -44,14 +42,21 @@ NginxDeploymentApiKeyRequestProperties, NginxDeploymentApiKeyResponse, NginxDeploymentApiKeyResponseProperties, + NginxDeploymentDefaultWafPolicyListResponse, + NginxDeploymentDefaultWafPolicyProperties, NginxDeploymentListResponse, NginxDeploymentProperties, - NginxDeploymentPropertiesNginxAppProtect, NginxDeploymentScalingProperties, NginxDeploymentUpdateParameters, NginxDeploymentUpdateProperties, - NginxDeploymentUpdatePropertiesNginxAppProtect, NginxDeploymentUserProfile, + NginxDeploymentWafPolicy, + NginxDeploymentWafPolicyApplyingStatus, + NginxDeploymentWafPolicyCompilingStatus, + NginxDeploymentWafPolicyListResponse, + NginxDeploymentWafPolicyMetadata, + NginxDeploymentWafPolicyMetadataProperties, + NginxDeploymentWafPolicyProperties, NginxFrontendIPConfiguration, NginxLogging, NginxNetworkInterfaceConfiguration, @@ -59,13 +64,15 @@ NginxPrivateIPAddress, NginxPublicIPAddress, NginxStorageAccount, + Operation, OperationDisplay, OperationListResult, - OperationResult, + ProxyResource, + Resource, ResourceSku, ScaleProfile, - ScaleProfileCapacity, SystemData, + TrackedResource, UserIdentityProperties, WebApplicationFirewallComponentVersions, WebApplicationFirewallPackage, @@ -74,11 +81,15 @@ ) from ._nginx_management_client_enums import ( # type: ignore + ActionType, ActivationState, CreatedByType, IdentityType, Level, + NginxDeploymentWafPolicyApplyingStatusCode, + NginxDeploymentWafPolicyCompilingStatusCode, NginxPrivateIPAllocationMethod, + Origin, ProvisioningState, ) from ._patch import __all__ as _patch_all @@ -87,10 +98,8 @@ __all__ = [ "AnalysisCreate", - "AnalysisCreateConfig", "AnalysisDiagnostic", "AnalysisResult", - "AnalysisResultData", "AutoUpgradeProfile", "DiagnosticItem", "ErrorAdditionalInfo", @@ -116,14 +125,21 @@ "NginxDeploymentApiKeyRequestProperties", "NginxDeploymentApiKeyResponse", "NginxDeploymentApiKeyResponseProperties", + "NginxDeploymentDefaultWafPolicyListResponse", + "NginxDeploymentDefaultWafPolicyProperties", "NginxDeploymentListResponse", "NginxDeploymentProperties", - "NginxDeploymentPropertiesNginxAppProtect", "NginxDeploymentScalingProperties", "NginxDeploymentUpdateParameters", "NginxDeploymentUpdateProperties", - "NginxDeploymentUpdatePropertiesNginxAppProtect", "NginxDeploymentUserProfile", + "NginxDeploymentWafPolicy", + "NginxDeploymentWafPolicyApplyingStatus", + "NginxDeploymentWafPolicyCompilingStatus", + "NginxDeploymentWafPolicyListResponse", + "NginxDeploymentWafPolicyMetadata", + "NginxDeploymentWafPolicyMetadataProperties", + "NginxDeploymentWafPolicyProperties", "NginxFrontendIPConfiguration", "NginxLogging", "NginxNetworkInterfaceConfiguration", @@ -131,23 +147,29 @@ "NginxPrivateIPAddress", "NginxPublicIPAddress", "NginxStorageAccount", + "Operation", "OperationDisplay", "OperationListResult", - "OperationResult", + "ProxyResource", + "Resource", "ResourceSku", "ScaleProfile", - "ScaleProfileCapacity", "SystemData", + "TrackedResource", "UserIdentityProperties", "WebApplicationFirewallComponentVersions", "WebApplicationFirewallPackage", "WebApplicationFirewallSettings", "WebApplicationFirewallStatus", + "ActionType", "ActivationState", "CreatedByType", "IdentityType", "Level", + "NginxDeploymentWafPolicyApplyingStatusCode", + "NginxDeploymentWafPolicyCompilingStatusCode", "NginxPrivateIPAllocationMethod", + "Origin", "ProvisioningState", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/models/_models_py3.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/models/_models_py3.py index d050ced9d383..5bd7389da9c2 100644 --- a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/models/_models_py3.py +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/models/_models_py3.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,44 +7,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping import datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Optional, TYPE_CHECKING, Union -from .. import _serialization +from .._utils import serialization as _serialization if TYPE_CHECKING: from .. import models as _models +JSON = MutableMapping[str, Any] class AnalysisCreate(_serialization.Model): """The request body for creating an analysis for an NGINX configuration. - All required parameters must be populated in order to send to server. - - :ivar config: Required. - :vartype config: ~azure.mgmt.nginx.models.AnalysisCreateConfig - """ - - _validation = { - "config": {"required": True}, - } - - _attribute_map = { - "config": {"key": "config", "type": "AnalysisCreateConfig"}, - } - - def __init__(self, *, config: "_models.AnalysisCreateConfig", **kwargs: Any) -> None: - """ - :keyword config: Required. - :paramtype config: ~azure.mgmt.nginx.models.AnalysisCreateConfig - """ - super().__init__(**kwargs) - self.config = config - - -class AnalysisCreateConfig(_serialization.Model): - """AnalysisCreateConfig. - :ivar root_file: The root file of the NGINX config file(s). It must match one of the files' filepath. :vartype root_file: str @@ -52,23 +28,23 @@ class AnalysisCreateConfig(_serialization.Model): :vartype files: list[~azure.mgmt.nginx.models.NginxConfigurationFile] :ivar protected_files: :vartype protected_files: list[~azure.mgmt.nginx.models.NginxConfigurationProtectedFileRequest] - :ivar package: + :ivar package: Nginx Configuration Package. :vartype package: ~azure.mgmt.nginx.models.NginxConfigurationPackage """ _attribute_map = { - "root_file": {"key": "rootFile", "type": "str"}, - "files": {"key": "files", "type": "[NginxConfigurationFile]"}, - "protected_files": {"key": "protectedFiles", "type": "[NginxConfigurationProtectedFileRequest]"}, - "package": {"key": "package", "type": "NginxConfigurationPackage"}, + "root_file": {"key": "config.rootFile", "type": "str"}, + "files": {"key": "config.files", "type": "[NginxConfigurationFile]"}, + "protected_files": {"key": "config.protectedFiles", "type": "[NginxConfigurationProtectedFileRequest]"}, + "package": {"key": "config.package", "type": "NginxConfigurationPackage"}, } def __init__( self, *, root_file: Optional[str] = None, - files: Optional[List["_models.NginxConfigurationFile"]] = None, - protected_files: Optional[List["_models.NginxConfigurationProtectedFileRequest"]] = None, + files: Optional[list["_models.NginxConfigurationFile"]] = None, + protected_files: Optional[list["_models.NginxConfigurationProtectedFileRequest"]] = None, package: Optional["_models.NginxConfigurationPackage"] = None, **kwargs: Any ) -> None: @@ -81,7 +57,7 @@ def __init__( :keyword protected_files: :paramtype protected_files: list[~azure.mgmt.nginx.models.NginxConfigurationProtectedFileRequest] - :keyword package: + :keyword package: Nginx Configuration Package. :paramtype package: ~azure.mgmt.nginx.models.NginxConfigurationPackage """ super().__init__(**kwargs) @@ -176,8 +152,10 @@ class AnalysisResult(_serialization.Model): :ivar status: The status of the analysis. Required. :vartype status: str - :ivar data: - :vartype data: ~azure.mgmt.nginx.models.AnalysisResultData + :ivar errors: + :vartype errors: list[~azure.mgmt.nginx.models.AnalysisDiagnostic] + :ivar diagnostics: + :vartype diagnostics: list[~azure.mgmt.nginx.models.DiagnosticItem] """ _validation = { @@ -186,49 +164,28 @@ class AnalysisResult(_serialization.Model): _attribute_map = { "status": {"key": "status", "type": "str"}, - "data": {"key": "data", "type": "AnalysisResultData"}, - } - - def __init__(self, *, status: str, data: Optional["_models.AnalysisResultData"] = None, **kwargs: Any) -> None: - """ - :keyword status: The status of the analysis. Required. - :paramtype status: str - :keyword data: - :paramtype data: ~azure.mgmt.nginx.models.AnalysisResultData - """ - super().__init__(**kwargs) - self.status = status - self.data = data - - -class AnalysisResultData(_serialization.Model): - """AnalysisResultData. - - :ivar errors: - :vartype errors: list[~azure.mgmt.nginx.models.AnalysisDiagnostic] - :ivar diagnostics: - :vartype diagnostics: list[~azure.mgmt.nginx.models.DiagnosticItem] - """ - - _attribute_map = { - "errors": {"key": "errors", "type": "[AnalysisDiagnostic]"}, - "diagnostics": {"key": "diagnostics", "type": "[DiagnosticItem]"}, + "errors": {"key": "data.errors", "type": "[AnalysisDiagnostic]"}, + "diagnostics": {"key": "data.diagnostics", "type": "[DiagnosticItem]"}, } def __init__( self, *, - errors: Optional[List["_models.AnalysisDiagnostic"]] = None, - diagnostics: Optional[List["_models.DiagnosticItem"]] = None, + status: str, + errors: Optional[list["_models.AnalysisDiagnostic"]] = None, + diagnostics: Optional[list["_models.DiagnosticItem"]] = None, **kwargs: Any ) -> None: """ + :keyword status: The status of the analysis. Required. + :paramtype status: str :keyword errors: :paramtype errors: list[~azure.mgmt.nginx.models.AnalysisDiagnostic] :keyword diagnostics: :paramtype diagnostics: list[~azure.mgmt.nginx.models.DiagnosticItem] """ super().__init__(**kwargs) + self.status = status self.errors = errors self.diagnostics = diagnostics @@ -377,8 +334,8 @@ class ErrorAdditionalInfo(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.type = None - self.info = None + self.type: Optional[str] = None + self.info: Optional[JSON] = None class ErrorDetail(_serialization.Model): @@ -417,11 +374,11 @@ class ErrorDetail(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None + self.code: Optional[str] = None + self.message: Optional[str] = None + self.target: Optional[str] = None + self.details: Optional[list["_models.ErrorDetail"]] = None + self.additional_info: Optional[list["_models.ErrorAdditionalInfo"]] = None class ErrorResponse(_serialization.Model): @@ -446,7 +403,7 @@ def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: A class IdentityProperties(_serialization.Model): - """IdentityProperties. + """Identity Properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -454,8 +411,8 @@ class IdentityProperties(_serialization.Model): :vartype principal_id: str :ivar tenant_id: :vartype tenant_id: str - :ivar type: Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", - and "None". + :ivar type: Identity Type. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, + UserAssigned", and "None". :vartype type: str or ~azure.mgmt.nginx.models.IdentityType :ivar user_assigned_identities: Dictionary of :code:``. :vartype user_assigned_identities: dict[str, ~azure.mgmt.nginx.models.UserIdentityProperties] @@ -477,40 +434,104 @@ def __init__( self, *, type: Optional[Union[str, "_models.IdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "_models.UserIdentityProperties"]] = None, + user_assigned_identities: Optional[dict[str, "_models.UserIdentityProperties"]] = None, **kwargs: Any ) -> None: """ - :keyword type: Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, - UserAssigned", and "None". + :keyword type: Identity Type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.nginx.models.IdentityType :keyword user_assigned_identities: Dictionary of :code:``. :paramtype user_assigned_identities: dict[str, ~azure.mgmt.nginx.models.UserIdentityProperties] """ super().__init__(**kwargs) - self.principal_id = None - self.tenant_id = None + self.principal_id: Optional[str] = None + self.tenant_id: Optional[str] = None self.type = type self.user_assigned_identities = user_assigned_identities -class NginxCertificate(_serialization.Model): - """NginxCertificate. +class Resource(_serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". :vartype id: str - :ivar name: + :ivar name: The name of the resource. :vartype name: str - :ivar type: + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.nginx.models.SystemData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.system_data: Optional["_models.SystemData"] = None + + +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have + tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.nginx.models.SystemData + """ + + +class NginxCertificate(ProxyResource): + """Nginx Certificate. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar properties: + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.nginx.models.SystemData + :ivar properties: Nginx Certificate Properties. :vartype properties: ~azure.mgmt.nginx.models.NginxCertificateProperties - :ivar location: + :ivar location: The geo-location where the resource lives. :vartype location: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.nginx.models.SystemData """ _validation = { @@ -524,9 +545,9 @@ class NginxCertificate(_serialization.Model): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "properties": {"key": "properties", "type": "NginxCertificateProperties"}, "location": {"key": "location", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, } def __init__( @@ -537,22 +558,18 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword properties: + :keyword properties: Nginx Certificate Properties. :paramtype properties: ~azure.mgmt.nginx.models.NginxCertificateProperties - :keyword location: + :keyword location: The geo-location where the resource lives. :paramtype location: str """ super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None self.properties = properties self.location = location - self.system_data = None class NginxCertificateErrorResponseBody(_serialization.Model): - """NginxCertificateErrorResponseBody. + """Nginx Certificate Error Response Body. :ivar code: :vartype code: str @@ -578,30 +595,32 @@ def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, class NginxCertificateListResponse(_serialization.Model): - """NginxCertificateListResponse. + """Nginx Certificate List Response. - :ivar value: + All required parameters must be populated in order to send to server. + + :ivar value: The NginxCertificate items on this page. Required. :vartype value: list[~azure.mgmt.nginx.models.NginxCertificate] - :ivar next_link: + :ivar next_link: The link to the next page of items. :vartype next_link: str """ + _validation = { + "value": {"required": True}, + } + _attribute_map = { "value": {"key": "value", "type": "[NginxCertificate]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.NginxCertificate"]] = None, - next_link: Optional[str] = None, - **kwargs: Any + self, *, value: list["_models.NginxCertificate"], next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword value: + :keyword value: The NginxCertificate items on this page. Required. :paramtype value: list[~azure.mgmt.nginx.models.NginxCertificate] - :keyword next_link: + :keyword next_link: The link to the next page of items. :paramtype next_link: str """ super().__init__(**kwargs) @@ -610,12 +629,12 @@ def __init__( class NginxCertificateProperties(_serialization.Model): - """NginxCertificateProperties. + """Nginx Certificate Properties. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: Known values are: "Accepted", "Creating", "Updating", "Deleting", - "Succeeded", "Failed", "Canceled", "Deleted", and "NotSpecified". + :ivar provisioning_state: Provisioning State. Known values are: "Accepted", "Creating", + "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", and "NotSpecified". :vartype provisioning_state: str or ~azure.mgmt.nginx.models.ProvisioningState :ivar key_virtual_path: :vartype key_virtual_path: str @@ -629,7 +648,7 @@ class NginxCertificateProperties(_serialization.Model): :vartype key_vault_secret_version: str :ivar key_vault_secret_created: :vartype key_vault_secret_created: ~datetime.datetime - :ivar certificate_error: + :ivar certificate_error: Nginx Certificate Error Response Body. :vartype certificate_error: ~azure.mgmt.nginx.models.NginxCertificateErrorResponseBody """ @@ -667,22 +686,22 @@ def __init__( :paramtype certificate_virtual_path: str :keyword key_vault_secret_id: :paramtype key_vault_secret_id: str - :keyword certificate_error: + :keyword certificate_error: Nginx Certificate Error Response Body. :paramtype certificate_error: ~azure.mgmt.nginx.models.NginxCertificateErrorResponseBody """ super().__init__(**kwargs) - self.provisioning_state = None + self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None self.key_virtual_path = key_virtual_path self.certificate_virtual_path = certificate_virtual_path self.key_vault_secret_id = key_vault_secret_id - self.sha1_thumbprint = None - self.key_vault_secret_version = None - self.key_vault_secret_created = None + self.sha1_thumbprint: Optional[str] = None + self.key_vault_secret_version: Optional[str] = None + self.key_vault_secret_created: Optional[datetime.datetime] = None self.certificate_error = certificate_error class NginxConfigurationFile(_serialization.Model): - """NginxConfigurationFile. + """Nginx Configuration File. :ivar content: :vartype content: str @@ -710,28 +729,30 @@ def __init__(self, *, content: Optional[str] = None, virtual_path: Optional[str] class NginxConfigurationListResponse(_serialization.Model): """Response of a list operation. - :ivar value: Results of a list operation. + All required parameters must be populated in order to send to server. + + :ivar value: The NginxConfigurationResponse items on this page. Required. :vartype value: list[~azure.mgmt.nginx.models.NginxConfigurationResponse] - :ivar next_link: Link to the next set of results, if any. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ + _validation = { + "value": {"required": True}, + } + _attribute_map = { "value": {"key": "value", "type": "[NginxConfigurationResponse]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.NginxConfigurationResponse"]] = None, - next_link: Optional[str] = None, - **kwargs: Any + self, *, value: list["_models.NginxConfigurationResponse"], next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword value: Results of a list operation. + :keyword value: The NginxConfigurationResponse items on this page. Required. :paramtype value: list[~azure.mgmt.nginx.models.NginxConfigurationResponse] - :keyword next_link: Link to the next set of results, if any. + :keyword next_link: The link to the next page of items. :paramtype next_link: str """ super().__init__(**kwargs) @@ -740,7 +761,7 @@ def __init__( class NginxConfigurationPackage(_serialization.Model): - """NginxConfigurationPackage. + """Nginx Configuration Package. :ivar data: :vartype data: str @@ -754,7 +775,7 @@ class NginxConfigurationPackage(_serialization.Model): } def __init__( - self, *, data: Optional[str] = None, protected_files: Optional[List[str]] = None, **kwargs: Any + self, *, data: Optional[str] = None, protected_files: Optional[list[str]] = None, **kwargs: Any ) -> None: """ :keyword data: @@ -768,7 +789,7 @@ def __init__( class NginxConfigurationProtectedFileRequest(_serialization.Model): - """NginxConfigurationProtectedFileRequest. + """Nginx Configuration Protected File Request. :ivar content: The content of the protected file. This value is a PUT only value. If you perform a GET request on this value, it will be empty because it is a protected file. @@ -811,7 +832,7 @@ def __init__( class NginxConfigurationProtectedFileResponse(_serialization.Model): - """NginxConfigurationProtectedFileResponse. + """Nginx Configuration Protected File Response. :ivar virtual_path: The virtual path of the protected file. :vartype virtual_path: str @@ -841,7 +862,7 @@ def __init__( class NginxConfigurationRequest(_serialization.Model): - """NginxConfigurationRequest. + """Nginx Configuration Request. Variables are only populated by the server, and will be ignored when sending a request. @@ -851,7 +872,7 @@ class NginxConfigurationRequest(_serialization.Model): :vartype name: str :ivar type: :vartype type: str - :ivar properties: + :ivar properties: Nginx Configuration Request Properties. :vartype properties: ~azure.mgmt.nginx.models.NginxConfigurationRequestProperties :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.nginx.models.SystemData @@ -876,30 +897,30 @@ def __init__( self, *, properties: Optional["_models.NginxConfigurationRequestProperties"] = None, **kwargs: Any ) -> None: """ - :keyword properties: + :keyword properties: Nginx Configuration Request Properties. :paramtype properties: ~azure.mgmt.nginx.models.NginxConfigurationRequestProperties """ super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None self.properties = properties - self.system_data = None + self.system_data: Optional["_models.SystemData"] = None class NginxConfigurationRequestProperties(_serialization.Model): - """NginxConfigurationRequestProperties. + """Nginx Configuration Request Properties. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: Known values are: "Accepted", "Creating", "Updating", "Deleting", - "Succeeded", "Failed", "Canceled", "Deleted", and "NotSpecified". + :ivar provisioning_state: Provisioning State. Known values are: "Accepted", "Creating", + "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", and "NotSpecified". :vartype provisioning_state: str or ~azure.mgmt.nginx.models.ProvisioningState :ivar files: :vartype files: list[~azure.mgmt.nginx.models.NginxConfigurationFile] :ivar protected_files: :vartype protected_files: list[~azure.mgmt.nginx.models.NginxConfigurationProtectedFileRequest] - :ivar package: + :ivar package: Nginx Configuration Package. :vartype package: ~azure.mgmt.nginx.models.NginxConfigurationPackage :ivar root_file: :vartype root_file: str @@ -920,8 +941,8 @@ class NginxConfigurationRequestProperties(_serialization.Model): def __init__( self, *, - files: Optional[List["_models.NginxConfigurationFile"]] = None, - protected_files: Optional[List["_models.NginxConfigurationProtectedFileRequest"]] = None, + files: Optional[list["_models.NginxConfigurationFile"]] = None, + protected_files: Optional[list["_models.NginxConfigurationProtectedFileRequest"]] = None, package: Optional["_models.NginxConfigurationPackage"] = None, root_file: Optional[str] = None, **kwargs: Any @@ -932,34 +953,37 @@ def __init__( :keyword protected_files: :paramtype protected_files: list[~azure.mgmt.nginx.models.NginxConfigurationProtectedFileRequest] - :keyword package: + :keyword package: Nginx Configuration Package. :paramtype package: ~azure.mgmt.nginx.models.NginxConfigurationPackage :keyword root_file: :paramtype root_file: str """ super().__init__(**kwargs) - self.provisioning_state = None + self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None self.files = files self.protected_files = protected_files self.package = package self.root_file = root_file -class NginxConfigurationResponse(_serialization.Model): - """NginxConfigurationResponse. +class NginxConfigurationResponse(ProxyResource): + """Nginx Configuration Response. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". :vartype id: str - :ivar name: + :ivar name: The name of the resource. :vartype name: str - :ivar type: + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar properties: - :vartype properties: ~azure.mgmt.nginx.models.NginxConfigurationResponseProperties - :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. :vartype system_data: ~azure.mgmt.nginx.models.SystemData + :ivar properties: Nginx Configuration Response Properties. + :vartype properties: ~azure.mgmt.nginx.models.NginxConfigurationResponseProperties """ _validation = { @@ -973,39 +997,35 @@ class NginxConfigurationResponse(_serialization.Model): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "properties": {"key": "properties", "type": "NginxConfigurationResponseProperties"}, "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "NginxConfigurationResponseProperties"}, } def __init__( self, *, properties: Optional["_models.NginxConfigurationResponseProperties"] = None, **kwargs: Any ) -> None: """ - :keyword properties: + :keyword properties: Nginx Configuration Response Properties. :paramtype properties: ~azure.mgmt.nginx.models.NginxConfigurationResponseProperties """ super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None self.properties = properties - self.system_data = None class NginxConfigurationResponseProperties(_serialization.Model): - """NginxConfigurationResponseProperties. + """Nginx Configuration Response Properties. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: Known values are: "Accepted", "Creating", "Updating", "Deleting", - "Succeeded", "Failed", "Canceled", "Deleted", and "NotSpecified". + :ivar provisioning_state: Provisioning State. Known values are: "Accepted", "Creating", + "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", and "NotSpecified". :vartype provisioning_state: str or ~azure.mgmt.nginx.models.ProvisioningState :ivar files: :vartype files: list[~azure.mgmt.nginx.models.NginxConfigurationFile] :ivar protected_files: :vartype protected_files: list[~azure.mgmt.nginx.models.NginxConfigurationProtectedFileResponse] - :ivar package: + :ivar package: Nginx Configuration Package. :vartype package: ~azure.mgmt.nginx.models.NginxConfigurationPackage :ivar root_file: :vartype root_file: str @@ -1026,8 +1046,8 @@ class NginxConfigurationResponseProperties(_serialization.Model): def __init__( self, *, - files: Optional[List["_models.NginxConfigurationFile"]] = None, - protected_files: Optional[List["_models.NginxConfigurationProtectedFileResponse"]] = None, + files: Optional[list["_models.NginxConfigurationFile"]] = None, + protected_files: Optional[list["_models.NginxConfigurationProtectedFileResponse"]] = None, package: Optional["_models.NginxConfigurationPackage"] = None, root_file: Optional[str] = None, **kwargs: Any @@ -1038,42 +1058,42 @@ def __init__( :keyword protected_files: :paramtype protected_files: list[~azure.mgmt.nginx.models.NginxConfigurationProtectedFileResponse] - :keyword package: + :keyword package: Nginx Configuration Package. :paramtype package: ~azure.mgmt.nginx.models.NginxConfigurationPackage :keyword root_file: :paramtype root_file: str """ super().__init__(**kwargs) - self.provisioning_state = None + self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None self.files = files self.protected_files = protected_files self.package = package self.root_file = root_file -class NginxDeployment(_serialization.Model): - """NginxDeployment. +class TrackedResource(Resource): + """The resource model definition for an Azure Resource Manager tracked top level resource which + has 'tags' and a 'location'. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: + All required parameters must be populated in order to send to server. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". :vartype id: str - :ivar name: + :ivar name: The name of the resource. :vartype name: str - :ivar type: + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar identity: - :vartype identity: ~azure.mgmt.nginx.models.IdentityProperties - :ivar properties: - :vartype properties: ~azure.mgmt.nginx.models.NginxDeploymentProperties - :ivar tags: Dictionary of :code:``. + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.nginx.models.SystemData + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar sku: - :vartype sku: ~azure.mgmt.nginx.models.ResourceSku - :ivar location: + :ivar location: The geo-location where the resource lives. Required. :vartype location: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.nginx.models.SystemData """ _validation = { @@ -1081,79 +1101,135 @@ class NginxDeployment(_serialization.Model): "name": {"readonly": True}, "type": {"readonly": True}, "system_data": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "identity": {"key": "identity", "type": "IdentityProperties"}, - "properties": {"key": "properties", "type": "NginxDeploymentProperties"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "ResourceSku"}, "location": {"key": "location", "type": "str"}, + } + + def __init__(self, *, location: str, tags: Optional[dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + """ + super().__init__(**kwargs) + self.tags = tags + self.location = location + + +class NginxDeployment(TrackedResource): + """Nginx Deployment. + + 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 server. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.nginx.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: Nginx Deployment Properties. + :vartype properties: ~azure.mgmt.nginx.models.NginxDeploymentProperties + :ivar identity: Identity Properties. + :vartype identity: ~azure.mgmt.nginx.models.IdentityProperties + :ivar sku: Resource Sku. + :vartype sku: ~azure.mgmt.nginx.models.ResourceSku + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "NginxDeploymentProperties"}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "sku": {"key": "sku", "type": "ResourceSku"}, } def __init__( self, *, - identity: Optional["_models.IdentityProperties"] = None, + location: str, + tags: Optional[dict[str, str]] = None, properties: Optional["_models.NginxDeploymentProperties"] = None, - tags: Optional[Dict[str, str]] = None, + identity: Optional["_models.IdentityProperties"] = None, sku: Optional["_models.ResourceSku"] = None, - location: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword identity: - :paramtype identity: ~azure.mgmt.nginx.models.IdentityProperties - :keyword properties: - :paramtype properties: ~azure.mgmt.nginx.models.NginxDeploymentProperties - :keyword tags: Dictionary of :code:``. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword sku: - :paramtype sku: ~azure.mgmt.nginx.models.ResourceSku - :keyword location: + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str + :keyword properties: Nginx Deployment Properties. + :paramtype properties: ~azure.mgmt.nginx.models.NginxDeploymentProperties + :keyword identity: Identity Properties. + :paramtype identity: ~azure.mgmt.nginx.models.IdentityProperties + :keyword sku: Resource Sku. + :paramtype sku: ~azure.mgmt.nginx.models.ResourceSku """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.identity = identity + super().__init__(tags=tags, location=location, **kwargs) self.properties = properties - self.tags = tags + self.identity = identity self.sku = sku - self.location = location - self.system_data = None class NginxDeploymentApiKeyListResponse(_serialization.Model): - """NginxDeploymentApiKeyListResponse. + """Nginx Deployment Api Key List Response. - :ivar value: + All required parameters must be populated in order to send to server. + + :ivar value: The NginxDeploymentApiKeyResponse items on this page. Required. :vartype value: list[~azure.mgmt.nginx.models.NginxDeploymentApiKeyResponse] - :ivar next_link: + :ivar next_link: The link to the next page of items. :vartype next_link: str """ + _validation = { + "value": {"required": True}, + } + _attribute_map = { "value": {"key": "value", "type": "[NginxDeploymentApiKeyResponse]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.NginxDeploymentApiKeyResponse"]] = None, - next_link: Optional[str] = None, - **kwargs: Any + self, *, value: list["_models.NginxDeploymentApiKeyResponse"], next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword value: + :keyword value: The NginxDeploymentApiKeyResponse items on this page. Required. :paramtype value: list[~azure.mgmt.nginx.models.NginxDeploymentApiKeyResponse] - :keyword next_link: + :keyword next_link: The link to the next page of items. :paramtype next_link: str """ super().__init__(**kwargs) @@ -1162,7 +1238,7 @@ def __init__( class NginxDeploymentApiKeyRequest(_serialization.Model): - """NginxDeploymentApiKeyRequest. + """Nginx Deployment Api Key Request. Variables are only populated by the server, and will be ignored when sending a request. @@ -1172,14 +1248,17 @@ class NginxDeploymentApiKeyRequest(_serialization.Model): :vartype name: str :ivar type: :vartype type: str - :ivar properties: + :ivar properties: Nginx Deployment Api Key Request Properties. :vartype properties: ~azure.mgmt.nginx.models.NginxDeploymentApiKeyRequestProperties + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.nginx.models.SystemData """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { @@ -1187,24 +1266,26 @@ class NginxDeploymentApiKeyRequest(_serialization.Model): "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "properties": {"key": "properties", "type": "NginxDeploymentApiKeyRequestProperties"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } def __init__( self, *, properties: Optional["_models.NginxDeploymentApiKeyRequestProperties"] = None, **kwargs: Any ) -> None: """ - :keyword properties: + :keyword properties: Nginx Deployment Api Key Request Properties. :paramtype properties: ~azure.mgmt.nginx.models.NginxDeploymentApiKeyRequestProperties """ super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None self.properties = properties + self.system_data: Optional["_models.SystemData"] = None class NginxDeploymentApiKeyRequestProperties(_serialization.Model): - """NginxDeploymentApiKeyRequestProperties. + """Nginx Deployment Api Key Request Properties. :ivar secret_text: Secret text to be used as a Dataplane API Key. This is a write only property that can never be read back, but the first three characters will be returned in the 'hint' @@ -1235,18 +1316,23 @@ def __init__( self.end_date_time = end_date_time -class NginxDeploymentApiKeyResponse(_serialization.Model): - """NginxDeploymentApiKeyResponse. +class NginxDeploymentApiKeyResponse(ProxyResource): + """Nginx Deployment Api Key Response. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". :vartype id: str - :ivar name: + :ivar name: The name of the resource. :vartype name: str - :ivar type: + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar properties: + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.nginx.models.SystemData + :ivar properties: Nginx Deployment Api Key Response Properties. :vartype properties: ~azure.mgmt.nginx.models.NginxDeploymentApiKeyResponseProperties """ @@ -1254,12 +1340,14 @@ class NginxDeploymentApiKeyResponse(_serialization.Model): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "properties": {"key": "properties", "type": "NginxDeploymentApiKeyResponseProperties"}, } @@ -1267,18 +1355,15 @@ def __init__( self, *, properties: Optional["_models.NginxDeploymentApiKeyResponseProperties"] = None, **kwargs: Any ) -> None: """ - :keyword properties: + :keyword properties: Nginx Deployment Api Key Response Properties. :paramtype properties: ~azure.mgmt.nginx.models.NginxDeploymentApiKeyResponseProperties """ super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None self.properties = properties class NginxDeploymentApiKeyResponseProperties(_serialization.Model): - """NginxDeploymentApiKeyResponseProperties. + """Nginx Deployment Api Key Response Properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1304,30 +1389,34 @@ def __init__(self, *, end_date_time: Optional[datetime.datetime] = None, **kwarg :paramtype end_date_time: ~datetime.datetime """ super().__init__(**kwargs) - self.hint = None + self.hint: Optional[str] = None self.end_date_time = end_date_time -class NginxDeploymentListResponse(_serialization.Model): - """NginxDeploymentListResponse. +class NginxDeploymentDefaultWafPolicyListResponse(_serialization.Model): # pylint: disable=name-too-long + """Nginx Deployment Default Waf Policy List Response. :ivar value: - :vartype value: list[~azure.mgmt.nginx.models.NginxDeployment] + :vartype value: list[~azure.mgmt.nginx.models.NginxDeploymentDefaultWafPolicyProperties] :ivar next_link: :vartype next_link: str """ _attribute_map = { - "value": {"key": "value", "type": "[NginxDeployment]"}, + "value": {"key": "value", "type": "[NginxDeploymentDefaultWafPolicyProperties]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, *, value: Optional[List["_models.NginxDeployment"]] = None, next_link: Optional[str] = None, **kwargs: Any + self, + *, + value: Optional[list["_models.NginxDeploymentDefaultWafPolicyProperties"]] = None, + next_link: Optional[str] = None, + **kwargs: Any ) -> None: """ :keyword value: - :paramtype value: list[~azure.mgmt.nginx.models.NginxDeployment] + :paramtype value: list[~azure.mgmt.nginx.models.NginxDeploymentDefaultWafPolicyProperties] :keyword next_link: :paramtype next_link: str """ @@ -1336,109 +1425,97 @@ def __init__( self.next_link = next_link -class NginxDeploymentProperties(_serialization.Model): - """NginxDeploymentProperties. +class NginxDeploymentDefaultWafPolicyProperties(_serialization.Model): # pylint: disable=name-too-long + """Nginx Deployment Default Waf Policy Properties. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: Known values are: "Accepted", "Creating", "Updating", "Deleting", - "Succeeded", "Failed", "Canceled", "Deleted", and "NotSpecified". - :vartype provisioning_state: str or ~azure.mgmt.nginx.models.ProvisioningState - :ivar nginx_version: - :vartype nginx_version: str - :ivar network_profile: - :vartype network_profile: ~azure.mgmt.nginx.models.NginxNetworkProfile - :ivar ip_address: The IP address of the deployment. - :vartype ip_address: str - :ivar enable_diagnostics_support: - :vartype enable_diagnostics_support: bool - :ivar logging: - :vartype logging: ~azure.mgmt.nginx.models.NginxLogging - :ivar scaling_properties: Information on how the deployment will be scaled. - :vartype scaling_properties: ~azure.mgmt.nginx.models.NginxDeploymentScalingProperties - :ivar auto_upgrade_profile: Autoupgrade settings of a deployment. - :vartype auto_upgrade_profile: ~azure.mgmt.nginx.models.AutoUpgradeProfile - :ivar user_profile: - :vartype user_profile: ~azure.mgmt.nginx.models.NginxDeploymentUserProfile - :ivar nginx_app_protect: Settings for NGINX App Protect (NAP). - :vartype nginx_app_protect: ~azure.mgmt.nginx.models.NginxDeploymentPropertiesNginxAppProtect - :ivar dataplane_api_endpoint: Dataplane API endpoint for the caller to update the NGINX state - of the deployment. - :vartype dataplane_api_endpoint: str + :ivar content: + :vartype content: bytes + :ivar filepath: + :vartype filepath: str """ _validation = { - "provisioning_state": {"readonly": True}, - "nginx_version": {"readonly": True}, - "ip_address": {"readonly": True}, - "dataplane_api_endpoint": {"readonly": True}, + "content": {"readonly": True}, + "filepath": {"readonly": True}, } _attribute_map = { - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "nginx_version": {"key": "nginxVersion", "type": "str"}, - "network_profile": {"key": "networkProfile", "type": "NginxNetworkProfile"}, - "ip_address": {"key": "ipAddress", "type": "str"}, - "enable_diagnostics_support": {"key": "enableDiagnosticsSupport", "type": "bool"}, - "logging": {"key": "logging", "type": "NginxLogging"}, - "scaling_properties": {"key": "scalingProperties", "type": "NginxDeploymentScalingProperties"}, - "auto_upgrade_profile": {"key": "autoUpgradeProfile", "type": "AutoUpgradeProfile"}, - "user_profile": {"key": "userProfile", "type": "NginxDeploymentUserProfile"}, - "nginx_app_protect": {"key": "nginxAppProtect", "type": "NginxDeploymentPropertiesNginxAppProtect"}, - "dataplane_api_endpoint": {"key": "dataplaneApiEndpoint", "type": "str"}, + "content": {"key": "content", "type": "bytearray"}, + "filepath": {"key": "filepath", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.content: Optional[bytes] = None + self.filepath: Optional[str] = None + + +class NginxDeploymentListResponse(_serialization.Model): + """Nginx Deployment List Response. + + All required parameters must be populated in order to send to server. + + :ivar value: The NginxDeployment items on this page. Required. + :vartype value: list[~azure.mgmt.nginx.models.NginxDeployment] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[NginxDeployment]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - network_profile: Optional["_models.NginxNetworkProfile"] = None, - enable_diagnostics_support: Optional[bool] = None, - logging: Optional["_models.NginxLogging"] = None, - scaling_properties: Optional["_models.NginxDeploymentScalingProperties"] = None, - auto_upgrade_profile: Optional["_models.AutoUpgradeProfile"] = None, - user_profile: Optional["_models.NginxDeploymentUserProfile"] = None, - nginx_app_protect: Optional["_models.NginxDeploymentPropertiesNginxAppProtect"] = None, - **kwargs: Any + self, *, value: list["_models.NginxDeployment"], next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword network_profile: - :paramtype network_profile: ~azure.mgmt.nginx.models.NginxNetworkProfile - :keyword enable_diagnostics_support: - :paramtype enable_diagnostics_support: bool - :keyword logging: - :paramtype logging: ~azure.mgmt.nginx.models.NginxLogging - :keyword scaling_properties: Information on how the deployment will be scaled. - :paramtype scaling_properties: ~azure.mgmt.nginx.models.NginxDeploymentScalingProperties - :keyword auto_upgrade_profile: Autoupgrade settings of a deployment. - :paramtype auto_upgrade_profile: ~azure.mgmt.nginx.models.AutoUpgradeProfile - :keyword user_profile: - :paramtype user_profile: ~azure.mgmt.nginx.models.NginxDeploymentUserProfile - :keyword nginx_app_protect: Settings for NGINX App Protect (NAP). - :paramtype nginx_app_protect: ~azure.mgmt.nginx.models.NginxDeploymentPropertiesNginxAppProtect + :keyword value: The NginxDeployment items on this page. Required. + :paramtype value: list[~azure.mgmt.nginx.models.NginxDeployment] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str """ super().__init__(**kwargs) - self.provisioning_state = None - self.nginx_version = None - self.network_profile = network_profile - self.ip_address = None - self.enable_diagnostics_support = enable_diagnostics_support - self.logging = logging - self.scaling_properties = scaling_properties - self.auto_upgrade_profile = auto_upgrade_profile - self.user_profile = user_profile - self.nginx_app_protect = nginx_app_protect - self.dataplane_api_endpoint = None + self.value = value + self.next_link = next_link -class NginxDeploymentPropertiesNginxAppProtect(_serialization.Model): - """Settings for NGINX App Protect (NAP). +class NginxDeploymentProperties(_serialization.Model): + """Nginx Deployment Properties. 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 server. - + :ivar provisioning_state: Provisioning State. Known values are: "Accepted", "Creating", + "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", and "NotSpecified". + :vartype provisioning_state: str or ~azure.mgmt.nginx.models.ProvisioningState + :ivar nginx_version: + :vartype nginx_version: str + :ivar network_profile: Nginx Network Profile. + :vartype network_profile: ~azure.mgmt.nginx.models.NginxNetworkProfile + :ivar ip_address: The IP address of the deployment. + :vartype ip_address: str + :ivar enable_diagnostics_support: + :vartype enable_diagnostics_support: bool + :ivar logging: Nginx Logging. + :vartype logging: ~azure.mgmt.nginx.models.NginxLogging + :ivar scaling_properties: Information on how the deployment will be scaled. + :vartype scaling_properties: ~azure.mgmt.nginx.models.NginxDeploymentScalingProperties + :ivar auto_upgrade_profile: Autoupgrade settings of a deployment. + :vartype auto_upgrade_profile: ~azure.mgmt.nginx.models.AutoUpgradeProfile + :ivar user_profile: Nginx Deployment User Profile. + :vartype user_profile: ~azure.mgmt.nginx.models.NginxDeploymentUserProfile + :ivar dataplane_api_endpoint: Dataplane API endpoint for the caller to update the NGINX state + of the deployment. + :vartype dataplane_api_endpoint: str :ivar web_application_firewall_settings: Settings for the NGINX App Protect Web Application - Firewall (WAF). Required. + Firewall (WAF). :vartype web_application_firewall_settings: ~azure.mgmt.nginx.models.WebApplicationFirewallSettings :ivar web_application_firewall_status: The status of the NGINX App Protect Web Application @@ -1447,33 +1524,77 @@ class NginxDeploymentPropertiesNginxAppProtect(_serialization.Model): """ _validation = { - "web_application_firewall_settings": {"required": True}, + "provisioning_state": {"readonly": True}, + "nginx_version": {"readonly": True}, + "ip_address": {"readonly": True}, + "dataplane_api_endpoint": {"readonly": True}, "web_application_firewall_status": {"readonly": True}, } _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "nginx_version": {"key": "nginxVersion", "type": "str"}, + "network_profile": {"key": "networkProfile", "type": "NginxNetworkProfile"}, + "ip_address": {"key": "ipAddress", "type": "str"}, + "enable_diagnostics_support": {"key": "enableDiagnosticsSupport", "type": "bool"}, + "logging": {"key": "logging", "type": "NginxLogging"}, + "scaling_properties": {"key": "scalingProperties", "type": "NginxDeploymentScalingProperties"}, + "auto_upgrade_profile": {"key": "autoUpgradeProfile", "type": "AutoUpgradeProfile"}, + "user_profile": {"key": "userProfile", "type": "NginxDeploymentUserProfile"}, + "dataplane_api_endpoint": {"key": "dataplaneApiEndpoint", "type": "str"}, "web_application_firewall_settings": { - "key": "webApplicationFirewallSettings", + "key": "nginxAppProtect.webApplicationFirewallSettings", "type": "WebApplicationFirewallSettings", }, "web_application_firewall_status": { - "key": "webApplicationFirewallStatus", + "key": "nginxAppProtect.webApplicationFirewallStatus", "type": "WebApplicationFirewallStatus", }, } def __init__( - self, *, web_application_firewall_settings: "_models.WebApplicationFirewallSettings", **kwargs: Any + self, + *, + network_profile: Optional["_models.NginxNetworkProfile"] = None, + enable_diagnostics_support: Optional[bool] = None, + logging: Optional["_models.NginxLogging"] = None, + scaling_properties: Optional["_models.NginxDeploymentScalingProperties"] = None, + auto_upgrade_profile: Optional["_models.AutoUpgradeProfile"] = None, + user_profile: Optional["_models.NginxDeploymentUserProfile"] = None, + web_application_firewall_settings: Optional["_models.WebApplicationFirewallSettings"] = None, + **kwargs: Any ) -> None: """ + :keyword network_profile: Nginx Network Profile. + :paramtype network_profile: ~azure.mgmt.nginx.models.NginxNetworkProfile + :keyword enable_diagnostics_support: + :paramtype enable_diagnostics_support: bool + :keyword logging: Nginx Logging. + :paramtype logging: ~azure.mgmt.nginx.models.NginxLogging + :keyword scaling_properties: Information on how the deployment will be scaled. + :paramtype scaling_properties: ~azure.mgmt.nginx.models.NginxDeploymentScalingProperties + :keyword auto_upgrade_profile: Autoupgrade settings of a deployment. + :paramtype auto_upgrade_profile: ~azure.mgmt.nginx.models.AutoUpgradeProfile + :keyword user_profile: Nginx Deployment User Profile. + :paramtype user_profile: ~azure.mgmt.nginx.models.NginxDeploymentUserProfile :keyword web_application_firewall_settings: Settings for the NGINX App Protect Web Application - Firewall (WAF). Required. + Firewall (WAF). :paramtype web_application_firewall_settings: ~azure.mgmt.nginx.models.WebApplicationFirewallSettings """ super().__init__(**kwargs) + self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None + self.nginx_version: Optional[str] = None + self.network_profile = network_profile + self.ip_address: Optional[str] = None + self.enable_diagnostics_support = enable_diagnostics_support + self.logging = logging + self.scaling_properties = scaling_properties + self.auto_upgrade_profile = auto_upgrade_profile + self.user_profile = user_profile + self.dataplane_api_endpoint: Optional[str] = None self.web_application_firewall_settings = web_application_firewall_settings - self.web_application_firewall_status = None + self.web_application_firewall_status: Optional["_models.WebApplicationFirewallStatus"] = None class NginxDeploymentScalingProperties(_serialization.Model): @@ -1491,7 +1612,7 @@ class NginxDeploymentScalingProperties(_serialization.Model): } def __init__( - self, *, capacity: Optional[int] = None, profiles: Optional[List["_models.ScaleProfile"]] = None, **kwargs: Any + self, *, capacity: Optional[int] = None, profiles: Optional[list["_models.ScaleProfile"]] = None, **kwargs: Any ) -> None: """ :keyword capacity: @@ -1505,17 +1626,17 @@ def __init__( class NginxDeploymentUpdateParameters(_serialization.Model): - """NginxDeploymentUpdateParameters. + """Nginx Deployment Update Parameters. - :ivar identity: + :ivar identity: Identity Properties. :vartype identity: ~azure.mgmt.nginx.models.IdentityProperties :ivar tags: Dictionary of :code:``. :vartype tags: dict[str, str] - :ivar sku: + :ivar sku: Resource Sku. :vartype sku: ~azure.mgmt.nginx.models.ResourceSku - :ivar location: + :ivar location: The geo-location where the resource lives. :vartype location: str - :ivar properties: + :ivar properties: Nginx Deployment Update Properties. :vartype properties: ~azure.mgmt.nginx.models.NginxDeploymentUpdateProperties """ @@ -1531,22 +1652,22 @@ def __init__( self, *, identity: Optional["_models.IdentityProperties"] = None, - tags: Optional[Dict[str, str]] = None, + tags: Optional[dict[str, str]] = None, sku: Optional["_models.ResourceSku"] = None, location: Optional[str] = None, properties: Optional["_models.NginxDeploymentUpdateProperties"] = None, **kwargs: Any ) -> None: """ - :keyword identity: + :keyword identity: Identity Properties. :paramtype identity: ~azure.mgmt.nginx.models.IdentityProperties :keyword tags: Dictionary of :code:``. :paramtype tags: dict[str, str] - :keyword sku: + :keyword sku: Resource Sku. :paramtype sku: ~azure.mgmt.nginx.models.ResourceSku - :keyword location: + :keyword location: The geo-location where the resource lives. :paramtype location: str - :keyword properties: + :keyword properties: Nginx Deployment Update Properties. :paramtype properties: ~azure.mgmt.nginx.models.NginxDeploymentUpdateProperties """ super().__init__(**kwargs) @@ -1558,23 +1679,24 @@ def __init__( class NginxDeploymentUpdateProperties(_serialization.Model): - """NginxDeploymentUpdateProperties. + """Nginx Deployment Update Properties. :ivar enable_diagnostics_support: :vartype enable_diagnostics_support: bool - :ivar logging: + :ivar logging: Nginx Logging. :vartype logging: ~azure.mgmt.nginx.models.NginxLogging :ivar scaling_properties: Information on how the deployment will be scaled. :vartype scaling_properties: ~azure.mgmt.nginx.models.NginxDeploymentScalingProperties - :ivar user_profile: + :ivar user_profile: Nginx Deployment User Profile. :vartype user_profile: ~azure.mgmt.nginx.models.NginxDeploymentUserProfile - :ivar network_profile: + :ivar network_profile: Nginx Network Profile. :vartype network_profile: ~azure.mgmt.nginx.models.NginxNetworkProfile :ivar auto_upgrade_profile: Autoupgrade settings of a deployment. :vartype auto_upgrade_profile: ~azure.mgmt.nginx.models.AutoUpgradeProfile - :ivar nginx_app_protect: Update settings for NGINX App Protect (NAP). - :vartype nginx_app_protect: - ~azure.mgmt.nginx.models.NginxDeploymentUpdatePropertiesNginxAppProtect + :ivar web_application_firewall_settings: Settings for the NGINX App Protect Web Application + Firewall (WAF). + :vartype web_application_firewall_settings: + ~azure.mgmt.nginx.models.WebApplicationFirewallSettings """ _attribute_map = { @@ -1584,7 +1706,10 @@ class NginxDeploymentUpdateProperties(_serialization.Model): "user_profile": {"key": "userProfile", "type": "NginxDeploymentUserProfile"}, "network_profile": {"key": "networkProfile", "type": "NginxNetworkProfile"}, "auto_upgrade_profile": {"key": "autoUpgradeProfile", "type": "AutoUpgradeProfile"}, - "nginx_app_protect": {"key": "nginxAppProtect", "type": "NginxDeploymentUpdatePropertiesNginxAppProtect"}, + "web_application_firewall_settings": { + "key": "nginxAppProtect.webApplicationFirewallSettings", + "type": "WebApplicationFirewallSettings", + }, } def __init__( @@ -1596,25 +1721,26 @@ def __init__( user_profile: Optional["_models.NginxDeploymentUserProfile"] = None, network_profile: Optional["_models.NginxNetworkProfile"] = None, auto_upgrade_profile: Optional["_models.AutoUpgradeProfile"] = None, - nginx_app_protect: Optional["_models.NginxDeploymentUpdatePropertiesNginxAppProtect"] = None, + web_application_firewall_settings: Optional["_models.WebApplicationFirewallSettings"] = None, **kwargs: Any ) -> None: """ :keyword enable_diagnostics_support: :paramtype enable_diagnostics_support: bool - :keyword logging: + :keyword logging: Nginx Logging. :paramtype logging: ~azure.mgmt.nginx.models.NginxLogging :keyword scaling_properties: Information on how the deployment will be scaled. :paramtype scaling_properties: ~azure.mgmt.nginx.models.NginxDeploymentScalingProperties - :keyword user_profile: + :keyword user_profile: Nginx Deployment User Profile. :paramtype user_profile: ~azure.mgmt.nginx.models.NginxDeploymentUserProfile - :keyword network_profile: + :keyword network_profile: Nginx Network Profile. :paramtype network_profile: ~azure.mgmt.nginx.models.NginxNetworkProfile :keyword auto_upgrade_profile: Autoupgrade settings of a deployment. :paramtype auto_upgrade_profile: ~azure.mgmt.nginx.models.AutoUpgradeProfile - :keyword nginx_app_protect: Update settings for NGINX App Protect (NAP). - :paramtype nginx_app_protect: - ~azure.mgmt.nginx.models.NginxDeploymentUpdatePropertiesNginxAppProtect + :keyword web_application_firewall_settings: Settings for the NGINX App Protect Web Application + Firewall (WAF). + :paramtype web_application_firewall_settings: + ~azure.mgmt.nginx.models.WebApplicationFirewallSettings """ super().__init__(**kwargs) self.enable_diagnostics_support = enable_diagnostics_support @@ -1623,69 +1749,321 @@ def __init__( self.user_profile = user_profile self.network_profile = network_profile self.auto_upgrade_profile = auto_upgrade_profile - self.nginx_app_protect = nginx_app_protect + self.web_application_firewall_settings = web_application_firewall_settings -class NginxDeploymentUpdatePropertiesNginxAppProtect(_serialization.Model): # pylint: disable=name-too-long - """Update settings for NGINX App Protect (NAP). +class NginxDeploymentUserProfile(_serialization.Model): + """Nginx Deployment User Profile. - :ivar web_application_firewall_settings: Settings for the NGINX App Protect Web Application - Firewall (WAF). - :vartype web_application_firewall_settings: - ~azure.mgmt.nginx.models.WebApplicationFirewallSettings + :ivar preferred_email: The preferred support contact email address of the user used for sending + alerts and notification. Can be an empty string or a valid email address. + :vartype preferred_email: str """ + _validation = { + "preferred_email": {"pattern": r"^$|^[A-Za-z0-9._%+-]+@(?:[A-Za-z0-9-]+\.)+[A-Za-z]{2,}$"}, + } + _attribute_map = { - "web_application_firewall_settings": { - "key": "webApplicationFirewallSettings", - "type": "WebApplicationFirewallSettings", - }, + "preferred_email": {"key": "preferredEmail", "type": "str"}, + } + + def __init__(self, *, preferred_email: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword preferred_email: The preferred support contact email address of the user used for + sending alerts and notification. Can be an empty string or a valid email address. + :paramtype preferred_email: str + """ + super().__init__(**kwargs) + self.preferred_email = preferred_email + + +class NginxDeploymentWafPolicy(ProxyResource): + """Nginx Deployment Waf Policy. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.nginx.models.SystemData + :ivar properties: Nginx Deployment Waf Policy Properties. + :vartype properties: ~azure.mgmt.nginx.models.NginxDeploymentWafPolicyProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "NginxDeploymentWafPolicyProperties"}, } def __init__( - self, - *, - web_application_firewall_settings: Optional["_models.WebApplicationFirewallSettings"] = None, - **kwargs: Any + self, *, properties: Optional["_models.NginxDeploymentWafPolicyProperties"] = None, **kwargs: Any ) -> None: """ - :keyword web_application_firewall_settings: Settings for the NGINX App Protect Web Application - Firewall (WAF). - :paramtype web_application_firewall_settings: - ~azure.mgmt.nginx.models.WebApplicationFirewallSettings + :keyword properties: Nginx Deployment Waf Policy Properties. + :paramtype properties: ~azure.mgmt.nginx.models.NginxDeploymentWafPolicyProperties """ super().__init__(**kwargs) - self.web_application_firewall_settings = web_application_firewall_settings + self.properties = properties -class NginxDeploymentUserProfile(_serialization.Model): - """NginxDeploymentUserProfile. +class NginxDeploymentWafPolicyApplyingStatus(_serialization.Model): + """Nginx Deployment Waf Policy Applying Status. - :ivar preferred_email: The preferred support contact email address of the user used for sending - alerts and notification. Can be an empty string or a valid email address. - :vartype preferred_email: str + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Machine readable code indicating the applying status code of a WAF Policy. Known + values are: "NotApplied", "Applying", "Succeeded", "Failed", and "Removing". + :vartype code: str or ~azure.mgmt.nginx.models.NginxDeploymentWafPolicyApplyingStatusCode + :ivar display_status: A readable string of the current status, and sometimes have the reason + for the current state. + :vartype display_status: str + :ivar time: The date and time in UTC the current applying status was set. + :vartype time: str """ _validation = { - "preferred_email": {"pattern": r"^$|^[A-Za-z0-9._%+-]+@(?:[A-Za-z0-9-]+\.)+[A-Za-z]{2,}$"}, + "code": {"readonly": True}, + "display_status": {"readonly": True}, + "time": {"readonly": True}, } _attribute_map = { - "preferred_email": {"key": "preferredEmail", "type": "str"}, + "code": {"key": "code", "type": "str"}, + "display_status": {"key": "displayStatus", "type": "str"}, + "time": {"key": "time", "type": "str"}, } - def __init__(self, *, preferred_email: Optional[str] = None, **kwargs: Any) -> None: + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code: Optional[Union[str, "_models.NginxDeploymentWafPolicyApplyingStatusCode"]] = None + self.display_status: Optional[str] = None + self.time: Optional[str] = None + + +class NginxDeploymentWafPolicyCompilingStatus(_serialization.Model): + """Nginx Deployment Waf Policy Compiling Status. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Machine readable code indicating the compilation status of a WAF Policy. Known + values are: "NotStarted", "InProgress", "Succeeded", and "Failed". + :vartype code: str or ~azure.mgmt.nginx.models.NginxDeploymentWafPolicyCompilingStatusCode + :ivar display_status: A readable string of the current status, and sometimes have the reason + for the current state. If the CompilingStatus is Failed the Display Status will be The waf + Policy failed to compile. + :vartype display_status: str + :ivar time: The date and time the policy was compiled in UTC. + :vartype time: str + """ + + _validation = { + "code": {"readonly": True}, + "display_status": {"readonly": True}, + "time": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "display_status": {"key": "displayStatus", "type": "str"}, + "time": {"key": "time", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code: Optional[Union[str, "_models.NginxDeploymentWafPolicyCompilingStatusCode"]] = None + self.display_status: Optional[str] = None + self.time: Optional[str] = None + + +class NginxDeploymentWafPolicyListResponse(_serialization.Model): + """Nginx Deployment Waf Policy List Response. + + All required parameters must be populated in order to send to server. + + :ivar value: The NginxDeploymentWafPolicyMetadata items on this page. Required. + :vartype value: list[~azure.mgmt.nginx.models.NginxDeploymentWafPolicyMetadata] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[NginxDeploymentWafPolicyMetadata]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: list["_models.NginxDeploymentWafPolicyMetadata"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ - :keyword preferred_email: The preferred support contact email address of the user used for - sending alerts and notification. Can be an empty string or a valid email address. - :paramtype preferred_email: str + :keyword value: The NginxDeploymentWafPolicyMetadata items on this page. Required. + :paramtype value: list[~azure.mgmt.nginx.models.NginxDeploymentWafPolicyMetadata] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str """ super().__init__(**kwargs) - self.preferred_email = preferred_email + self.value = value + self.next_link = next_link + + +class NginxDeploymentWafPolicyMetadata(_serialization.Model): + """Nginx Deployment Waf Policy Metadata. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: + :vartype id: str + :ivar name: + :vartype name: str + :ivar type: + :vartype type: str + :ivar properties: Nginx Deployment Waf Policy Metadata Properties. + :vartype properties: ~azure.mgmt.nginx.models.NginxDeploymentWafPolicyMetadataProperties + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.nginx.models.SystemData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "NginxDeploymentWafPolicyMetadataProperties"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__( + self, *, properties: Optional["_models.NginxDeploymentWafPolicyMetadataProperties"] = None, **kwargs: Any + ) -> None: + """ + :keyword properties: Nginx Deployment Waf Policy Metadata Properties. + :paramtype properties: ~azure.mgmt.nginx.models.NginxDeploymentWafPolicyMetadataProperties + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.properties = properties + self.system_data: Optional["_models.SystemData"] = None + + +class NginxDeploymentWafPolicyMetadataProperties(_serialization.Model): # pylint: disable=name-too-long + """Nginx Deployment Waf Policy Metadata Properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar filepath: + :vartype filepath: str + :ivar provisioning_state: Provisioning State. Known values are: "Accepted", "Creating", + "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", and "NotSpecified". + :vartype provisioning_state: str or ~azure.mgmt.nginx.models.ProvisioningState + :ivar compiling_state: Nginx Deployment Waf Policy Compiling Status. + :vartype compiling_state: ~azure.mgmt.nginx.models.NginxDeploymentWafPolicyCompilingStatus + :ivar applying_state: Nginx Deployment Waf Policy Applying Status. + :vartype applying_state: ~azure.mgmt.nginx.models.NginxDeploymentWafPolicyApplyingStatus + """ + + _validation = { + "filepath": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "compiling_state": {"readonly": True}, + "applying_state": {"readonly": True}, + } + + _attribute_map = { + "filepath": {"key": "filepath", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "compiling_state": {"key": "compilingState", "type": "NginxDeploymentWafPolicyCompilingStatus"}, + "applying_state": {"key": "applyingState", "type": "NginxDeploymentWafPolicyApplyingStatus"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.filepath: Optional[str] = None + self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None + self.compiling_state: Optional["_models.NginxDeploymentWafPolicyCompilingStatus"] = None + self.applying_state: Optional["_models.NginxDeploymentWafPolicyApplyingStatus"] = None + + +class NginxDeploymentWafPolicyProperties(_serialization.Model): + """Nginx Deployment Waf Policy Properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: Provisioning State. Known values are: "Accepted", "Creating", + "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", and "NotSpecified". + :vartype provisioning_state: str or ~azure.mgmt.nginx.models.ProvisioningState + :ivar content: The byte content of the Policy. + :vartype content: bytes + :ivar filepath: The file path where the Policy is to be saved. + :vartype filepath: str + :ivar compiling_state: Nginx Deployment Waf Policy Compiling Status. + :vartype compiling_state: ~azure.mgmt.nginx.models.NginxDeploymentWafPolicyCompilingStatus + :ivar applying_state: Nginx Deployment Waf Policy Applying Status. + :vartype applying_state: ~azure.mgmt.nginx.models.NginxDeploymentWafPolicyApplyingStatus + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "compiling_state": {"readonly": True}, + "applying_state": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "content": {"key": "content", "type": "bytearray"}, + "filepath": {"key": "filepath", "type": "str"}, + "compiling_state": {"key": "compilingState", "type": "NginxDeploymentWafPolicyCompilingStatus"}, + "applying_state": {"key": "applyingState", "type": "NginxDeploymentWafPolicyApplyingStatus"}, + } + + def __init__(self, *, content: Optional[bytes] = None, filepath: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword content: The byte content of the Policy. + :paramtype content: bytes + :keyword filepath: The file path where the Policy is to be saved. + :paramtype filepath: str + """ + super().__init__(**kwargs) + self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None + self.content = content + self.filepath = filepath + self.compiling_state: Optional["_models.NginxDeploymentWafPolicyCompilingStatus"] = None + self.applying_state: Optional["_models.NginxDeploymentWafPolicyApplyingStatus"] = None class NginxFrontendIPConfiguration(_serialization.Model): - """NginxFrontendIPConfiguration. + """Nginx Frontend IP Configuration. :ivar public_ip_addresses: :vartype public_ip_addresses: list[~azure.mgmt.nginx.models.NginxPublicIPAddress] @@ -1701,8 +2079,8 @@ class NginxFrontendIPConfiguration(_serialization.Model): def __init__( self, *, - public_ip_addresses: Optional[List["_models.NginxPublicIPAddress"]] = None, - private_ip_addresses: Optional[List["_models.NginxPrivateIPAddress"]] = None, + public_ip_addresses: Optional[list["_models.NginxPublicIPAddress"]] = None, + private_ip_addresses: Optional[list["_models.NginxPrivateIPAddress"]] = None, **kwargs: Any ) -> None: """ @@ -1717,9 +2095,9 @@ def __init__( class NginxLogging(_serialization.Model): - """NginxLogging. + """Nginx Logging. - :ivar storage_account: + :ivar storage_account: Nginx Storage Account. :vartype storage_account: ~azure.mgmt.nginx.models.NginxStorageAccount """ @@ -1729,7 +2107,7 @@ class NginxLogging(_serialization.Model): def __init__(self, *, storage_account: Optional["_models.NginxStorageAccount"] = None, **kwargs: Any) -> None: """ - :keyword storage_account: + :keyword storage_account: Nginx Storage Account. :paramtype storage_account: ~azure.mgmt.nginx.models.NginxStorageAccount """ super().__init__(**kwargs) @@ -1737,7 +2115,7 @@ def __init__(self, *, storage_account: Optional["_models.NginxStorageAccount"] = class NginxNetworkInterfaceConfiguration(_serialization.Model): - """NginxNetworkInterfaceConfiguration. + """Nginx Network Interface Configuration. :ivar subnet_id: :vartype subnet_id: str @@ -1757,11 +2135,11 @@ def __init__(self, *, subnet_id: Optional[str] = None, **kwargs: Any) -> None: class NginxNetworkProfile(_serialization.Model): - """NginxNetworkProfile. + """Nginx Network Profile. - :ivar front_end_ip_configuration: + :ivar front_end_ip_configuration: Nginx Frontend IP Configuration. :vartype front_end_ip_configuration: ~azure.mgmt.nginx.models.NginxFrontendIPConfiguration - :ivar network_interface_configuration: + :ivar network_interface_configuration: Nginx Network Interface Configuration. :vartype network_interface_configuration: ~azure.mgmt.nginx.models.NginxNetworkInterfaceConfiguration """ @@ -1782,9 +2160,9 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword front_end_ip_configuration: + :keyword front_end_ip_configuration: Nginx Frontend IP Configuration. :paramtype front_end_ip_configuration: ~azure.mgmt.nginx.models.NginxFrontendIPConfiguration - :keyword network_interface_configuration: + :keyword network_interface_configuration: Nginx Network Interface Configuration. :paramtype network_interface_configuration: ~azure.mgmt.nginx.models.NginxNetworkInterfaceConfiguration """ @@ -1794,11 +2172,12 @@ def __init__( class NginxPrivateIPAddress(_serialization.Model): - """NginxPrivateIPAddress. + """Nginx Private IP Address. :ivar private_ip_address: :vartype private_ip_address: str - :ivar private_ip_allocation_method: Known values are: "Static" and "Dynamic". + :ivar private_ip_allocation_method: Nginx Private IP Allocation Method. Known values are: + "Static" and "Dynamic". :vartype private_ip_allocation_method: str or ~azure.mgmt.nginx.models.NginxPrivateIPAllocationMethod :ivar subnet_id: @@ -1822,7 +2201,8 @@ def __init__( """ :keyword private_ip_address: :paramtype private_ip_address: str - :keyword private_ip_allocation_method: Known values are: "Static" and "Dynamic". + :keyword private_ip_allocation_method: Nginx Private IP Allocation Method. Known values are: + "Static" and "Dynamic". :paramtype private_ip_allocation_method: str or ~azure.mgmt.nginx.models.NginxPrivateIPAllocationMethod :keyword subnet_id: @@ -1835,7 +2215,7 @@ def __init__( class NginxPublicIPAddress(_serialization.Model): - """NginxPublicIPAddress. + """Nginx Public IP Address. :ivar id: :vartype id: str @@ -1855,7 +2235,7 @@ def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylin class NginxStorageAccount(_serialization.Model): - """NginxStorageAccount. + """Nginx Storage Account. :ivar account_name: :vartype account_name: str @@ -1882,19 +2262,82 @@ def __init__( self.container_name = container_name +class Operation(_serialization.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :ivar display: Localized display information for this particular operation. + :vartype display: ~azure.mgmt.nginx.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", + and "user,system". + :vartype origin: str or ~azure.mgmt.nginx.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. "Internal" + :vartype action_type: str or ~azure.mgmt.nginx.models.ActionType + """ + + _validation = { + "name": {"readonly": True}, + "is_data_action": {"readonly": True}, + "origin": {"readonly": True}, + "action_type": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "action_type": {"key": "actionType", "type": "str"}, + } + + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any) -> None: + """ + :keyword display: Localized display information for this particular operation. + :paramtype display: ~azure.mgmt.nginx.models.OperationDisplay + """ + super().__init__(**kwargs) + self.name: Optional[str] = None + self.is_data_action: Optional[bool] = None + self.display = display + self.origin: Optional[Union[str, "_models.Origin"]] = None + self.action_type: Optional[Union[str, "_models.ActionType"]] = None + + class OperationDisplay(_serialization.Model): - """The object that represents the operation. + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. - :ivar provider: Service provider: Nginx.NginxPlus. + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". :vartype provider: str - :ivar resource: Type on which the operation is performed, e.g., 'deployments'. + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". :vartype resource: str - :ivar operation: Operation type, e.g., read, write, delete, etc. + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". :vartype operation: str - :ivar description: Description of the operation, e.g., 'Write deployments'. + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. :vartype description: str """ + _validation = { + "provider": {"readonly": True}, + "resource": {"readonly": True}, + "operation": {"readonly": True}, + "description": {"readonly": True}, + } + _attribute_map = { "provider": {"key": "provider", "type": "str"}, "resource": {"key": "resource", "type": "str"}, @@ -1902,101 +2345,46 @@ class OperationDisplay(_serialization.Model): "description": {"key": "description", "type": "str"}, } - def __init__( - self, - *, - provider: Optional[str] = None, - resource: Optional[str] = None, - operation: Optional[str] = None, - description: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword provider: Service provider: Nginx.NginxPlus. - :paramtype provider: str - :keyword resource: Type on which the operation is performed, e.g., 'deployments'. - :paramtype resource: str - :keyword operation: Operation type, e.g., read, write, delete, etc. - :paramtype operation: str - :keyword description: Description of the operation, e.g., 'Write deployments'. - :paramtype description: str - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.provider = provider - self.resource = resource - self.operation = operation - self.description = description + self.provider: Optional[str] = None + self.resource: Optional[str] = None + self.operation: Optional[str] = None + self.description: Optional[str] = None class OperationListResult(_serialization.Model): - """Result of GET request to list Nginx.NginxPlus operations. + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link + to get the next set of results. - :ivar value: List of operations supported by the Nginx.NginxPlus provider. - :vartype value: list[~azure.mgmt.nginx.models.OperationResult] - :ivar next_link: URL to get the next set of operation list results if there are any. + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~azure.mgmt.nginx.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). :vartype next_link: str """ - _attribute_map = { - "value": {"key": "value", "type": "[OperationResult]"}, - "next_link": {"key": "nextLink", "type": "str"}, + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, } - def __init__( - self, *, value: Optional[List["_models.OperationResult"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: List of operations supported by the Nginx.NginxPlus provider. - :paramtype value: list[~azure.mgmt.nginx.models.OperationResult] - :keyword next_link: URL to get the next set of operation list results if there are any. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class OperationResult(_serialization.Model): - """A Nginx.NginxPlus REST API operation. - - :ivar name: Operation name: {provider}/{resource}/{operation}. - :vartype name: str - :ivar display: The object that represents the operation. - :vartype display: ~azure.mgmt.nginx.models.OperationDisplay - :ivar is_data_action: Indicates whether the operation is a data action. - :vartype is_data_action: bool - """ - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display": {"key": "display", "type": "OperationDisplay"}, - "is_data_action": {"key": "isDataAction", "type": "bool"}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display: Optional["_models.OperationDisplay"] = None, - is_data_action: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Operation name: {provider}/{resource}/{operation}. - :paramtype name: str - :keyword display: The object that represents the operation. - :paramtype display: ~azure.mgmt.nginx.models.OperationDisplay - :keyword is_data_action: Indicates whether the operation is a data action. - :paramtype is_data_action: bool - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.name = name - self.display = display - self.is_data_action = is_data_action + self.value: Optional[list["_models.Operation"]] = None + self.next_link: Optional[str] = None class ResourceSku(_serialization.Model): - """ResourceSku. + """Resource Sku. All required parameters must be populated in order to send to server. @@ -2028,37 +2416,6 @@ class ScaleProfile(_serialization.Model): :ivar name: Required. :vartype name: str - :ivar capacity: The capacity parameters of the profile. Required. - :vartype capacity: ~azure.mgmt.nginx.models.ScaleProfileCapacity - """ - - _validation = { - "name": {"required": True}, - "capacity": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "capacity": {"key": "capacity", "type": "ScaleProfileCapacity"}, - } - - def __init__(self, *, name: str, capacity: "_models.ScaleProfileCapacity", **kwargs: Any) -> None: - """ - :keyword name: Required. - :paramtype name: str - :keyword capacity: The capacity parameters of the profile. Required. - :paramtype capacity: ~azure.mgmt.nginx.models.ScaleProfileCapacity - """ - super().__init__(**kwargs) - self.name = name - self.capacity = capacity - - -class ScaleProfileCapacity(_serialization.Model): - """The capacity parameters of the profile. - - All required parameters must be populated in order to send to server. - :ivar min: The minimum number of NCUs the deployment can be autoscaled to. Required. :vartype min: int :ivar max: The maximum number of NCUs the deployment can be autoscaled to. Required. @@ -2066,29 +2423,35 @@ class ScaleProfileCapacity(_serialization.Model): """ _validation = { - "min": {"required": True, "minimum": 0}, - "max": {"required": True, "minimum": 0}, + "name": {"required": True}, + "min": {"required": True}, + "max": {"required": True}, } _attribute_map = { - "min": {"key": "min", "type": "int"}, - "max": {"key": "max", "type": "int"}, + "name": {"key": "name", "type": "str"}, + "min": {"key": "capacity.min", "type": "int"}, + "max": {"key": "capacity.max", "type": "int"}, } def __init__( self, *, + name: str, min: int, # pylint: disable=redefined-builtin max: int, # pylint: disable=redefined-builtin **kwargs: Any ) -> None: """ + :keyword name: Required. + :paramtype name: str :keyword min: The minimum number of NCUs the deployment can be autoscaled to. Required. :paramtype min: int :keyword max: The maximum number of NCUs the deployment can be autoscaled to. Required. :paramtype max: int """ super().__init__(**kwargs) + self.name = name self.min = min self.max = max @@ -2158,7 +2521,7 @@ def __init__( class UserIdentityProperties(_serialization.Model): - """UserIdentityProperties. + """User Identity Properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -2181,8 +2544,8 @@ class UserIdentityProperties(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.principal_id = None - self.client_id = None + self.principal_id: Optional[str] = None + self.client_id: Optional[str] = None class WebApplicationFirewallComponentVersions(_serialization.Model): @@ -2287,6 +2650,8 @@ class WebApplicationFirewallStatus(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. + :ivar waf_release: NGINX App Protect WAF release version. + :vartype waf_release: str :ivar attack_signatures_package: Package containing attack signatures for the NGINX App Protect Web Application Firewall (WAF). :vartype attack_signatures_package: ~azure.mgmt.nginx.models.WebApplicationFirewallPackage @@ -2309,16 +2674,21 @@ class WebApplicationFirewallStatus(_serialization.Model): } _attribute_map = { + "waf_release": {"key": "wafRelease", "type": "str"}, "attack_signatures_package": {"key": "attackSignaturesPackage", "type": "WebApplicationFirewallPackage"}, "bot_signatures_package": {"key": "botSignaturesPackage", "type": "WebApplicationFirewallPackage"}, "threat_campaigns_package": {"key": "threatCampaignsPackage", "type": "WebApplicationFirewallPackage"}, "component_versions": {"key": "componentVersions", "type": "WebApplicationFirewallComponentVersions"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, waf_release: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword waf_release: NGINX App Protect WAF release version. + :paramtype waf_release: str + """ super().__init__(**kwargs) - self.attack_signatures_package = None - self.bot_signatures_package = None - self.threat_campaigns_package = None - self.component_versions = None + self.waf_release = waf_release + self.attack_signatures_package: Optional["_models.WebApplicationFirewallPackage"] = None + self.bot_signatures_package: Optional["_models.WebApplicationFirewallPackage"] = None + self.threat_campaigns_package: Optional["_models.WebApplicationFirewallPackage"] = None + self.component_versions: Optional["_models.WebApplicationFirewallComponentVersions"] = None diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/models/_nginx_management_client_enums.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/models/_nginx_management_client_enums.py index 9d6b8d706b9f..c2b10e80087a 100644 --- a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/models/_nginx_management_client_enums.py +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/models/_nginx_management_client_enums.py @@ -10,6 +10,12 @@ from azure.core import CaseInsensitiveEnumMeta +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.""" + + INTERNAL = "Internal" + + class ActivationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The activation state of the WAF. Use 'Enabled' to enable the WAF and 'Disabled' to disable it.""" @@ -27,7 +33,7 @@ class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """IdentityType.""" + """Identity Type.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" @@ -42,15 +48,55 @@ class Level(str, Enum, metaclass=CaseInsensitiveEnumMeta): WARNING = "Warning" +class NginxDeploymentWafPolicyApplyingStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Machine readable code indicating the applying status code of a WAF Policy.""" + + NOT_APPLIED = "NotApplied" + """The policy is not referenced in the nginx config and not applied.""" + APPLYING = "Applying" + """The policy is referenced in the nginx config and is applying.""" + SUCCEEDED = "Succeeded" + """The policy is referenced in the nginx config and that config has been successfully applied.""" + FAILED = "Failed" + """The policy is referenced in the nginx config and that config failed to apply.""" + REMOVING = "Removing" + """The policy is now not referenced in the nginx config and its being removed from the applied + nginx config.""" + + +class NginxDeploymentWafPolicyCompilingStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Machine readable code indicating the compilation status of a WAF Policy.""" + + NOT_STARTED = "NotStarted" + """The compilation of the custom waf policy has not started""" + IN_PROGRESS = "InProgress" + """The compilation of the custom waf policy is in progress""" + SUCCEEDED = "Succeeded" + """The compilation of the custom waf policy is completed successfully and can now be referenced in + the nginx config.""" + FAILED = "Failed" + """The compilation of the custom waf policy failed.""" + + class NginxPrivateIPAllocationMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """NginxPrivateIPAllocationMethod.""" + """Nginx Private IP Allocation Method.""" STATIC = "Static" DYNAMIC = "Dynamic" +class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is "user,system". + """ + + USER = "user" + SYSTEM = "system" + USER_SYSTEM = "user,system" + + class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ProvisioningState.""" + """Provisioning State.""" ACCEPTED = "Accepted" CREATING = "Creating" diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/models/_patch.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/models/_patch.py index f7dd32510333..87676c65a8f0 100644 --- a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/models/_patch.py +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/models/_patch.py @@ -1,14 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/__init__.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/__init__.py index bf1dfbd4df3e..8896f281e12d 100644 --- a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/__init__.py +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/__init__.py @@ -12,22 +12,26 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import +from ._operations import Operations # type: ignore +from ._deployments_operations import DeploymentsOperations # type: ignore from ._api_keys_operations import ApiKeysOperations # type: ignore from ._certificates_operations import CertificatesOperations # type: ignore from ._configurations_operations import ConfigurationsOperations # type: ignore -from ._deployments_operations import DeploymentsOperations # type: ignore -from ._operations import Operations # type: ignore +from ._default_waf_policy_operations import DefaultWafPolicyOperations # type: ignore +from ._waf_policy_operations import WafPolicyOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ + "Operations", + "DeploymentsOperations", "ApiKeysOperations", "CertificatesOperations", "ConfigurationsOperations", - "DeploymentsOperations", - "Operations", + "DefaultWafPolicyOperations", + "WafPolicyOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_api_keys_operations.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_api_keys_operations.py index b4d2368903b6..aefc2fd007d9 100644 --- a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_api_keys_operations.py +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_api_keys_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,11 +6,12 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from typing import Any, Callable, IO, Optional, TypeVar, Union, overload import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -26,34 +28,31 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._serialization import Serializer +from .._configuration import NginxManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] +List = list _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_create_or_update_request( - resource_group_name: str, deployment_name: str, api_key_name: str, subscription_id: str, **kwargs: Any +def build_list_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/apiKeys/{apiKeyName}", - ) # pylint: disable=line-too-long + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/apiKeys", + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -65,9 +64,6 @@ def build_create_or_update_request( "str", pattern=r"^([a-z0-9A-Z][a-z0-9A-Z-]{0,28}[a-z0-9A-Z]|[a-z0-9A-Z])$", ), - "apiKeyName": _SERIALIZER.url( - "api_key_name", api_key_name, "str", pattern=r"^([a-z0-9A-Z][a-z0-9A-Z-]{0,28}[a-z0-9A-Z]|[a-z0-9A-Z])$" - ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -76,27 +72,25 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_get_request( resource_group_name: str, deployment_name: str, api_key_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/apiKeys/{apiKeyName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -121,23 +115,24 @@ def build_delete_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_request( +def build_create_or_update_request( resource_group_name: str, deployment_name: str, api_key_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/apiKeys/{apiKeyName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -160,25 +155,27 @@ def build_get_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any +def build_delete_request( + resource_group_name: str, deployment_name: str, api_key_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/apiKeys", - ) # pylint: disable=line-too-long + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/apiKeys/{apiKeyName}", + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -190,6 +187,9 @@ def build_list_request( "str", pattern=r"^([a-z0-9A-Z][a-z0-9A-Z-]{0,28}[a-z0-9A-Z]|[a-z0-9A-Z])$", ), + "apiKeyName": _SERIALIZER.url( + "api_key_name", api_key_name, "str", pattern=r"^([a-z0-9A-Z][a-z0-9A-Z-]{0,28}[a-z0-9A-Z]|[a-z0-9A-Z])$" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -200,7 +200,7 @@ def build_list_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) class ApiKeysOperations: @@ -215,12 +215,158 @@ class ApiKeysOperations: models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: NginxManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> ItemPaged["_models.NginxDeploymentApiKeyResponse"]: + """List all API Keys of the given Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of targeted NGINX deployment. Required. + :type deployment_name: str + :return: An iterator like instance of either NginxDeploymentApiKeyResponse or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.nginx.models.NginxDeploymentApiKeyResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NginxDeploymentApiKeyListResponse] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("NginxDeploymentApiKeyListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, deployment_name: str, api_key_name: str, **kwargs: Any + ) -> _models.NginxDeploymentApiKeyResponse: + """Get the specified API Key of the given Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of targeted NGINX deployment. Required. + :type deployment_name: str + :param api_key_name: The resource name of the API key. Required. + :type api_key_name: str + :return: NginxDeploymentApiKeyResponse or the result of cls(response) + :rtype: ~azure.mgmt.nginx.models.NginxDeploymentApiKeyResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NginxDeploymentApiKeyResponse] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + api_key_name=api_key_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NginxDeploymentApiKeyResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @overload def create_or_update( @@ -236,9 +382,6 @@ def create_or_update( """Create or update an API Key for the Nginx deployment in order to access the dataplane API endpoint. - Create or update an API Key for the Nginx deployment in order to access the dataplane API - endpoint. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -271,9 +414,6 @@ def create_or_update( """Create or update an API Key for the Nginx deployment in order to access the dataplane API endpoint. - Create or update an API Key for the Nginx deployment in order to access the dataplane API - endpoint. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -304,9 +444,6 @@ def create_or_update( """Create or update an API Key for the Nginx deployment in order to access the dataplane API endpoint. - Create or update an API Key for the Nginx deployment in order to access the dataplane API - endpoint. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -335,9 +472,10 @@ def create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None cls: ClsType[_models.NginxDeploymentApiKeyResponse] = kwargs.pop("cls", None) - content_type = content_type or "application/json" + content_type = content_type or "application/json" if body else None _json = None _content = None if isinstance(body, (IOBase, bytes)): @@ -387,8 +525,6 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete API key for Nginx deployment. - Delete API key for Nginx deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -439,153 +575,3 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def get( - self, resource_group_name: str, deployment_name: str, api_key_name: str, **kwargs: Any - ) -> _models.NginxDeploymentApiKeyResponse: - """Get the specified API Key of the given Nginx deployment. - - Get the specified API Key of the given Nginx deployment. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param deployment_name: The name of targeted NGINX deployment. Required. - :type deployment_name: str - :param api_key_name: The resource name of the API key. Required. - :type api_key_name: str - :return: NginxDeploymentApiKeyResponse or the result of cls(response) - :rtype: ~azure.mgmt.nginx.models.NginxDeploymentApiKeyResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.NginxDeploymentApiKeyResponse] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - api_key_name=api_key_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("NginxDeploymentApiKeyResponse", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, deployment_name: str, **kwargs: Any - ) -> Iterable["_models.NginxDeploymentApiKeyResponse"]: - """List all API Keys of the given Nginx deployment. - - List all API Keys of the given Nginx deployment. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param deployment_name: The name of targeted NGINX deployment. Required. - :type deployment_name: str - :return: An iterator like instance of either NginxDeploymentApiKeyResponse or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.nginx.models.NginxDeploymentApiKeyResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.NginxDeploymentApiKeyListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("NginxDeploymentApiKeyListResponse", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_certificates_operations.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_certificates_operations.py index 8caee16fcec7..1c436c87d967 100644 --- a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_certificates_operations.py +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_certificates_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,11 +6,12 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -30,33 +32,31 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._serialization import Serializer +from .._configuration import NginxManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] +List = list _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - resource_group_name: str, deployment_name: str, certificate_name: str, subscription_id: str, **kwargs: Any +def build_list_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/certificates/{certificateName}", - ) # pylint: disable=line-too-long + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/certificates", + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -68,7 +68,6 @@ def build_get_request( "str", pattern=r"^([a-z0-9A-Z][a-z0-9A-Z-]{0,28}[a-z0-9A-Z]|[a-z0-9A-Z])$", ), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -82,21 +81,20 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_get_request( resource_group_name: str, deployment_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/certificates/{certificateName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -108,7 +106,12 @@ def build_create_or_update_request( "str", pattern=r"^([a-z0-9A-Z][a-z0-9A-Z-]{0,28}[a-z0-9A-Z]|[a-z0-9A-Z])$", ), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", + certificate_name, + "str", + pattern=r"^([a-z0-9A-Z][a-z0-9A-Z-]{0,28}[a-z0-9A-Z]|[a-z0-9A-Z])$", + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -117,27 +120,26 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_create_or_update_request( resource_group_name: str, deployment_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/certificates/{certificateName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -149,7 +151,12 @@ def build_delete_request( "str", pattern=r"^([a-z0-9A-Z][a-z0-9A-Z-]{0,28}[a-z0-9A-Z]|[a-z0-9A-Z])$", ), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", + certificate_name, + "str", + pattern=r"^([a-z0-9A-Z][a-z0-9A-Z-]{0,28}[a-z0-9A-Z]|[a-z0-9A-Z])$", + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -158,25 +165,27 @@ def build_delete_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any +def build_delete_request( + resource_group_name: str, deployment_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/certificates", - ) # pylint: disable=line-too-long + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/certificates/{certificateName}", + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -188,6 +197,12 @@ def build_list_request( "str", pattern=r"^([a-z0-9A-Z][a-z0-9A-Z-]{0,28}[a-z0-9A-Z]|[a-z0-9A-Z])$", ), + "certificateName": _SERIALIZER.url( + "certificate_name", + certificate_name, + "str", + pattern=r"^([a-z0-9A-Z][a-z0-9A-Z-]{0,28}[a-z0-9A-Z]|[a-z0-9A-Z])$", + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -198,7 +213,7 @@ def build_list_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) class CertificatesOperations: @@ -213,12 +228,96 @@ class CertificatesOperations: models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: NginxManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> ItemPaged["_models.NginxCertificate"]: + """List all certificates of given NGINX deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of targeted NGINX deployment. Required. + :type deployment_name: str + :return: An iterator like instance of either NginxCertificate or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.nginx.models.NginxCertificate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NginxCertificateListResponse] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("NginxCertificateListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) @distributed_trace def get( @@ -226,8 +325,6 @@ def get( ) -> _models.NginxCertificate: """Get a certificate of given NGINX deployment. - Get a certificate of given NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -304,9 +401,10 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" + content_type = content_type or "application/json" if body else None _json = None _content = None if isinstance(body, (IOBase, bytes)): @@ -348,10 +446,17 @@ def _create_or_update_initial( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -368,8 +473,6 @@ def begin_create_or_update( ) -> LROPoller[_models.NginxCertificate]: """Create or update the NGINX certificates for given NGINX deployment. - Create or update the NGINX certificates for given NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -401,8 +504,6 @@ def begin_create_or_update( ) -> LROPoller[_models.NginxCertificate]: """Create or update the NGINX certificates for given NGINX deployment. - Create or update the NGINX certificates for given NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -432,8 +533,6 @@ def begin_create_or_update( ) -> LROPoller[_models.NginxCertificate]: """Create or update the NGINX certificates for given NGINX deployment. - Create or update the NGINX certificates for given NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -454,6 +553,7 @@ def begin_create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None cls: ClsType[_models.NginxCertificate] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -535,7 +635,7 @@ def _delete_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [202, 204]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -544,10 +644,15 @@ def _delete_initial( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -557,8 +662,6 @@ def begin_delete( ) -> LROPoller[None]: """Deletes a certificate from the NGINX deployment. - Deletes a certificate from the NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -597,7 +700,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -610,89 +715,3 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, deployment_name: str, **kwargs: Any - ) -> Iterable["_models.NginxCertificate"]: - """List all certificates of given NGINX deployment. - - List all certificates of given NGINX deployment. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param deployment_name: The name of targeted NGINX deployment. Required. - :type deployment_name: str - :return: An iterator like instance of either NginxCertificate or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.nginx.models.NginxCertificate] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.NginxCertificateListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("NginxCertificateListResponse", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_configurations_operations.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_configurations_operations.py index 6c10036b327c..8c7fd553851f 100644 --- a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_configurations_operations.py +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,11 +6,12 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -30,14 +32,12 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._serialization import Serializer +from .._configuration import NginxManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] +List = list _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False @@ -49,14 +49,14 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/configurations", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -87,14 +87,14 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/configurations/{configurationName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -106,7 +106,9 @@ def build_get_request( "str", pattern=r"^([a-z0-9A-Z][a-z0-9A-Z-]{0,28}[a-z0-9A-Z]|[a-z0-9A-Z])$", ), - "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "str"), + "configurationName": _SERIALIZER.url( + "configuration_name", configuration_name, "str", pattern=r"^[a-z][a-z0-9]*$" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -126,7 +128,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -134,7 +136,7 @@ def build_create_or_update_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/configurations/{configurationName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -146,7 +148,9 @@ def build_create_or_update_request( "str", pattern=r"^([a-z0-9A-Z][a-z0-9A-Z-]{0,28}[a-z0-9A-Z]|[a-z0-9A-Z])$", ), - "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "str"), + "configurationName": _SERIALIZER.url( + "configuration_name", configuration_name, "str", pattern=r"^[a-z][a-z0-9]*$" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -168,14 +172,14 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/configurations/{configurationName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -187,7 +191,9 @@ def build_delete_request( "str", pattern=r"^([a-z0-9A-Z][a-z0-9A-Z-]{0,28}[a-z0-9A-Z]|[a-z0-9A-Z])$", ), - "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "str"), + "configurationName": _SERIALIZER.url( + "configuration_name", configuration_name, "str", pattern=r"^[a-z][a-z0-9]*$" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -207,7 +213,7 @@ def build_analysis_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -215,7 +221,7 @@ def build_analysis_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/configurations/{configurationName}/analyze", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -257,21 +263,19 @@ class ConfigurationsOperations: models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: NginxManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, resource_group_name: str, deployment_name: str, **kwargs: Any - ) -> Iterable["_models.NginxConfigurationResponse"]: + ) -> ItemPaged["_models.NginxConfigurationResponse"]: """List the NGINX configuration of given NGINX deployment. - List the NGINX configuration of given NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -357,8 +361,6 @@ def get( ) -> _models.NginxConfigurationResponse: """Get the NGINX configuration of given NGINX deployment. - Get the NGINX configuration of given NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -436,9 +438,10 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" + content_type = content_type or "application/json" if body else None _json = None _content = None if isinstance(body, (IOBase, bytes)): @@ -480,10 +483,17 @@ def _create_or_update_initial( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -500,8 +510,6 @@ def begin_create_or_update( ) -> LROPoller[_models.NginxConfigurationResponse]: """Create or update the NGINX configuration for given NGINX deployment. - Create or update the NGINX configuration for given NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -534,8 +542,6 @@ def begin_create_or_update( ) -> LROPoller[_models.NginxConfigurationResponse]: """Create or update the NGINX configuration for given NGINX deployment. - Create or update the NGINX configuration for given NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -566,8 +572,6 @@ def begin_create_or_update( ) -> LROPoller[_models.NginxConfigurationResponse]: """Create or update the NGINX configuration for given NGINX deployment. - Create or update the NGINX configuration for given NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -589,6 +593,7 @@ def begin_create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None cls: ClsType[_models.NginxConfigurationResponse] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -670,7 +675,7 @@ def _delete_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [202, 204]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -679,10 +684,15 @@ def _delete_initial( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -692,8 +702,6 @@ def begin_delete( ) -> LROPoller[None]: """Reset the NGINX configuration of given NGINX deployment to default. - Reset the NGINX configuration of given NGINX deployment to default. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -733,7 +741,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -760,8 +770,6 @@ def analysis( ) -> _models.AnalysisResult: """Analyze an NGINX configuration without applying it to the NGINXaaS deployment. - Analyze an NGINX configuration without applying it to the NGINXaaS deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -793,8 +801,6 @@ def analysis( ) -> _models.AnalysisResult: """Analyze an NGINX configuration without applying it to the NGINXaaS deployment. - Analyze an NGINX configuration without applying it to the NGINXaaS deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -824,8 +830,6 @@ def analysis( ) -> _models.AnalysisResult: """Analyze an NGINX configuration without applying it to the NGINXaaS deployment. - Analyze an NGINX configuration without applying it to the NGINXaaS deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -854,9 +858,10 @@ def analysis( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None cls: ClsType[_models.AnalysisResult] = kwargs.pop("cls", None) - content_type = content_type or "application/json" + content_type = content_type or "application/json" if body else None _json = None _content = None if isinstance(body, (IOBase, bytes)): diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_default_waf_policy_operations.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_default_waf_policy_operations.py new file mode 100644 index 000000000000..aa9fd8369f0b --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_default_waf_policy_operations.py @@ -0,0 +1,152 @@ +# pylint: disable=line-too-long,useless-suppression +# 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 collections.abc import MutableMapping +from typing import Any, Callable, Optional, TypeVar + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import NginxManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] +List = list + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/listDefaultWafPolicies", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", + deployment_name, + "str", + pattern=r"^([a-z0-9A-Z][a-z0-9A-Z-]{0,28}[a-z0-9A-Z]|[a-z0-9A-Z])$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class DefaultWafPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.nginx.NginxManagementClient`'s + :attr:`default_waf_policy` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: NginxManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.NginxDeploymentDefaultWafPolicyListResponse: + """Get the Nginx Waf Policy of given Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of targeted NGINX deployment. Required. + :type deployment_name: str + :return: NginxDeploymentDefaultWafPolicyListResponse or the result of cls(response) + :rtype: ~azure.mgmt.nginx.models.NginxDeploymentDefaultWafPolicyListResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NginxDeploymentDefaultWafPolicyListResponse] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NginxDeploymentDefaultWafPolicyListResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_deployments_operations.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_deployments_operations.py index 816e201aa2fa..e991560ff2bf 100644 --- a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_deployments_operations.py +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_deployments_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,11 +6,12 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -30,44 +32,28 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._serialization import Serializer +from .._configuration import NginxManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] +List = list _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}", - ) # pylint: disable=line-too-long + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Nginx.NginxPlus/nginxDeployments") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "deploymentName": _SERIALIZER.url( - "deployment_name", - deployment_name, - "str", - pattern=r"^([a-z0-9A-Z][a-z0-9A-Z-]{0,28}[a-z0-9A-Z]|[a-z0-9A-Z])$", - ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -81,32 +67,23 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( - resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}", - ) # pylint: disable=line-too-long + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments", + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "deploymentName": _SERIALIZER.url( - "deployment_name", - deployment_name, - "str", - pattern=r"^([a-z0-9A-Z][a-z0-9A-Z-]{0,28}[a-z0-9A-Z]|[a-z0-9A-Z])$", - ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -115,28 +92,25 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request( +def build_get_request( resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -156,27 +130,26 @@ def build_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_create_or_update_request( resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -196,22 +169,39 @@ def build_delete_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_update_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Nginx.NginxPlus/nginxDeployments") + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}", + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", + deployment_name, + "str", + pattern=r"^([a-z0-9A-Z][a-z0-9A-Z-]{0,28}[a-z0-9A-Z]|[a-z0-9A-Z])$", + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -220,28 +210,38 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_delete_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments", - ) # pylint: disable=line-too-long + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}", + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), + "deploymentName": _SERIALIZER.url( + "deployment_name", + deployment_name, + "str", + pattern=r"^([a-z0-9A-Z][a-z0-9A-Z-]{0,28}[a-z0-9A-Z]|[a-z0-9A-Z])$", + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -252,7 +252,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) class DeploymentsOperations: @@ -267,19 +267,171 @@ class DeploymentsOperations: models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: NginxManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged["_models.NginxDeployment"]: + """List the NGINX deployments resources. + + :return: An iterator like instance of either NginxDeployment or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.nginx.models.NginxDeployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NginxDeploymentListResponse] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("NginxDeploymentListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.NginxDeployment"]: + """List all NGINX deployments under the specified resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either NginxDeployment or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.nginx.models.NginxDeployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NginxDeploymentListResponse] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("NginxDeploymentListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) @distributed_trace def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.NginxDeployment: """Get the NGINX deployment. - Get the NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -352,9 +504,10 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" + content_type = content_type or "application/json" if body else None _json = None _content = None if isinstance(body, (IOBase, bytes)): @@ -395,10 +548,17 @@ def _create_or_update_initial( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -414,14 +574,12 @@ def begin_create_or_update( ) -> LROPoller[_models.NginxDeployment]: """Create or update the NGINX deployment. - Create or update the NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param deployment_name: The name of targeted NGINX deployment. Required. :type deployment_name: str - :param body: Default value is None. + :param body: The Nginx deployment. Default value is None. :type body: ~azure.mgmt.nginx.models.NginxDeployment :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -444,14 +602,12 @@ def begin_create_or_update( ) -> LROPoller[_models.NginxDeployment]: """Create or update the NGINX deployment. - Create or update the NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param deployment_name: The name of targeted NGINX deployment. Required. :type deployment_name: str - :param body: Default value is None. + :param body: The Nginx deployment. Default value is None. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -472,14 +628,13 @@ def begin_create_or_update( ) -> LROPoller[_models.NginxDeployment]: """Create or update the NGINX deployment. - Create or update the NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param deployment_name: The name of targeted NGINX deployment. Required. :type deployment_name: str - :param body: Is either a NginxDeployment type or a IO[bytes] type. Default value is None. + :param body: The Nginx deployment. Is either a NginxDeployment type or a IO[bytes] type. + Default value is None. :type body: ~azure.mgmt.nginx.models.NginxDeployment or IO[bytes] :return: An instance of LROPoller that returns either NginxDeployment or the result of cls(response) @@ -491,6 +646,7 @@ def begin_create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None cls: ClsType[_models.NginxDeployment] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -555,9 +711,10 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" + content_type = content_type or "application/json" if body else None _json = None _content = None if isinstance(body, (IOBase, bytes)): @@ -589,7 +746,7 @@ def _update_initial( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -598,10 +755,17 @@ def _update_initial( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -617,14 +781,12 @@ def begin_update( ) -> LROPoller[_models.NginxDeployment]: """Update the NGINX deployment. - Update the NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param deployment_name: The name of targeted NGINX deployment. Required. :type deployment_name: str - :param body: Default value is None. + :param body: The Nginx deployment update parameters. Default value is None. :type body: ~azure.mgmt.nginx.models.NginxDeploymentUpdateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -647,14 +809,12 @@ def begin_update( ) -> LROPoller[_models.NginxDeployment]: """Update the NGINX deployment. - Update the NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param deployment_name: The name of targeted NGINX deployment. Required. :type deployment_name: str - :param body: Default value is None. + :param body: The Nginx deployment update parameters. Default value is None. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -675,15 +835,13 @@ def begin_update( ) -> LROPoller[_models.NginxDeployment]: """Update the NGINX deployment. - Update the NGINX deployment. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param deployment_name: The name of targeted NGINX deployment. Required. :type deployment_name: str - :param body: Is either a NginxDeploymentUpdateParameters type or a IO[bytes] type. Default - value is None. + :param body: The Nginx deployment update parameters. Is either a + NginxDeploymentUpdateParameters type or a IO[bytes] type. Default value is None. :type body: ~azure.mgmt.nginx.models.NginxDeploymentUpdateParameters or IO[bytes] :return: An instance of LROPoller that returns either NginxDeployment or the result of cls(response) @@ -695,6 +853,7 @@ def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None cls: ClsType[_models.NginxDeployment] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -721,7 +880,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -770,7 +931,7 @@ def _delete_initial(self, resource_group_name: str, deployment_name: str, **kwar response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [202, 204]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -779,10 +940,15 @@ def _delete_initial(self, resource_group_name: str, deployment_name: str, **kwar error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -790,8 +956,6 @@ def _delete_initial(self, resource_group_name: str, deployment_name: str, **kwar def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Delete the NGINX deployment resource. - Delete the NGINX deployment resource. - :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str @@ -827,7 +991,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -840,161 +1006,3 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.NginxDeployment"]: - """List the NGINX deployments resources. - - List the NGINX deployments resources. - - :return: An iterator like instance of either NginxDeployment or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.nginx.models.NginxDeployment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.NginxDeploymentListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("NginxDeploymentListResponse", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.NginxDeployment"]: - """List all NGINX deployments under the specified resource group. - - List all NGINX deployments under the specified resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :return: An iterator like instance of either NginxDeployment or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.nginx.models.NginxDeployment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.NginxDeploymentListResponse] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("NginxDeploymentListResponse", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_operations.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_operations.py index b7ece36d4268..fa1073663ef3 100644 --- a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_operations.py +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_operations.py @@ -5,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from collections.abc import MutableMapping +from typing import Any, Callable, Optional, TypeVar import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -25,14 +26,12 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._serialization import Serializer +from .._configuration import NginxManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] +List = list _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False @@ -42,7 +41,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -69,21 +68,19 @@ class Operations: models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: NginxManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.OperationResult"]: - """List all operations provided by Nginx.NginxPlus for the 2024-11-01-preview api version. + def list(self, **kwargs: Any) -> ItemPaged["_models.Operation"]: + """List the operations for the provider. - List all operations provided by Nginx.NginxPlus for the 2024-11-01-preview api version. - - :return: An iterator like instance of either OperationResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.nginx.models.OperationResult] + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.nginx.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_patch.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_patch.py index f7dd32510333..87676c65a8f0 100644 --- a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_patch.py +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_patch.py @@ -1,14 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_waf_policy_operations.py b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_waf_policy_operations.py new file mode 100644 index 000000000000..d87dc92e40a4 --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/azure/mgmt/nginx/operations/_waf_policy_operations.py @@ -0,0 +1,719 @@ +# pylint: disable=line-too-long,useless-suppression +# 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 collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import NginxManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] +List = list + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/wafPolicies", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", + deployment_name, + "str", + pattern=r"^([a-z0-9A-Z][a-z0-9A-Z-]{0,28}[a-z0-9A-Z]|[a-z0-9A-Z])$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, deployment_name: str, waf_policy_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/wafPolicies/{wafPolicyName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", + deployment_name, + "str", + pattern=r"^([a-z0-9A-Z][a-z0-9A-Z-]{0,28}[a-z0-9A-Z]|[a-z0-9A-Z])$", + ), + "wafPolicyName": _SERIALIZER.url( + "waf_policy_name", + waf_policy_name, + "str", + pattern=r"^([a-z0-9A-Z][a-z0-9A-Z-]{0,28}[a-z0-9A-Z]|[a-z0-9A-Z])$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, deployment_name: str, waf_policy_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/wafPolicies/{wafPolicyName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", + deployment_name, + "str", + pattern=r"^([a-z0-9A-Z][a-z0-9A-Z-]{0,28}[a-z0-9A-Z]|[a-z0-9A-Z])$", + ), + "wafPolicyName": _SERIALIZER.url( + "waf_policy_name", + waf_policy_name, + "str", + pattern=r"^([a-z0-9A-Z][a-z0-9A-Z-]{0,28}[a-z0-9A-Z]|[a-z0-9A-Z])$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, deployment_name: str, waf_policy_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/wafPolicies/{wafPolicyName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", + deployment_name, + "str", + pattern=r"^([a-z0-9A-Z][a-z0-9A-Z-]{0,28}[a-z0-9A-Z]|[a-z0-9A-Z])$", + ), + "wafPolicyName": _SERIALIZER.url( + "waf_policy_name", + waf_policy_name, + "str", + pattern=r"^([a-z0-9A-Z][a-z0-9A-Z-]{0,28}[a-z0-9A-Z]|[a-z0-9A-Z])$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WafPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.nginx.NginxManagementClient`'s + :attr:`waf_policy` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: NginxManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> ItemPaged["_models.NginxDeploymentWafPolicyMetadata"]: + """List Waf Policies of given Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of targeted NGINX deployment. Required. + :type deployment_name: str + :return: An iterator like instance of either NginxDeploymentWafPolicyMetadata or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.nginx.models.NginxDeploymentWafPolicyMetadata] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NginxDeploymentWafPolicyListResponse] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("NginxDeploymentWafPolicyListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, deployment_name: str, waf_policy_name: str, **kwargs: Any + ) -> _models.NginxDeploymentWafPolicy: + """Get the Nginx Waf Policy of given Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of targeted NGINX deployment. Required. + :type deployment_name: str + :param waf_policy_name: The name of Waf Policy. Required. + :type waf_policy_name: str + :return: NginxDeploymentWafPolicy or the result of cls(response) + :rtype: ~azure.mgmt.nginx.models.NginxDeploymentWafPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NginxDeploymentWafPolicy] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + waf_policy_name=waf_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NginxDeploymentWafPolicy", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + deployment_name: str, + waf_policy_name: str, + body: Optional[Union[_models.NginxDeploymentWafPolicy, IO[bytes]]] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if body else None + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "NginxDeploymentWafPolicy") + else: + _json = None + + _request = build_create_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + waf_policy_name=waf_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + deployment_name: str, + waf_policy_name: str, + body: Optional[_models.NginxDeploymentWafPolicy] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.NginxDeploymentWafPolicy]: + """Create or update the Nginx Waf Policy for given Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of targeted NGINX deployment. Required. + :type deployment_name: str + :param waf_policy_name: The name of Waf Policy. Required. + :type waf_policy_name: str + :param body: The Nginx Deployment Waf Policy. Default value is None. + :type body: ~azure.mgmt.nginx.models.NginxDeploymentWafPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either NginxDeploymentWafPolicy or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.nginx.models.NginxDeploymentWafPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + deployment_name: str, + waf_policy_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.NginxDeploymentWafPolicy]: + """Create or update the Nginx Waf Policy for given Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of targeted NGINX deployment. Required. + :type deployment_name: str + :param waf_policy_name: The name of Waf Policy. Required. + :type waf_policy_name: str + :param body: The Nginx Deployment Waf Policy. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either NginxDeploymentWafPolicy or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.nginx.models.NginxDeploymentWafPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + deployment_name: str, + waf_policy_name: str, + body: Optional[Union[_models.NginxDeploymentWafPolicy, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.NginxDeploymentWafPolicy]: + """Create or update the Nginx Waf Policy for given Nginx deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of targeted NGINX deployment. Required. + :type deployment_name: str + :param waf_policy_name: The name of Waf Policy. Required. + :type waf_policy_name: str + :param body: The Nginx Deployment Waf Policy. Is either a NginxDeploymentWafPolicy type or a + IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.nginx.models.NginxDeploymentWafPolicy or IO[bytes] + :return: An instance of LROPoller that returns either NginxDeploymentWafPolicy or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.nginx.models.NginxDeploymentWafPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None + cls: ClsType[_models.NginxDeploymentWafPolicy] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + waf_policy_name=waf_policy_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("NginxDeploymentWafPolicy", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.NginxDeploymentWafPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.NginxDeploymentWafPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, deployment_name: str, waf_policy_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + waf_policy_name=waf_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, deployment_name: str, waf_policy_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Reset the Nginx Waf Policy of given Nginx deployment to default. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of targeted NGINX deployment. Required. + :type deployment_name: str + :param waf_policy_name: The name of Waf Policy. Required. + :type waf_policy_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + waf_policy_name=waf_policy_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/nginx/azure-mgmt-nginx/generated_samples/api_keys_create_or_update.py b/sdk/nginx/azure-mgmt-nginx/generated_samples/api_keys_create_or_update.py index 66c898cc6ead..a23d93cd26b3 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_samples/api_keys_create_or_update.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_samples/api_keys_create_or_update.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/ApiKeys_CreateOrUpdate.json +# x-ms-original-file: specification/nginx/resource-manager/Nginx.NginxPlus/preview/2025-03-01-preview/examples/ApiKeys_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/nginx/azure-mgmt-nginx/generated_samples/api_keys_delete.py b/sdk/nginx/azure-mgmt-nginx/generated_samples/api_keys_delete.py index 1d3d1f295162..2fdb061bab78 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_samples/api_keys_delete.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_samples/api_keys_delete.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/ApiKeys_Delete.json +# x-ms-original-file: specification/nginx/resource-manager/Nginx.NginxPlus/preview/2025-03-01-preview/examples/ApiKeys_Delete.json if __name__ == "__main__": main() diff --git a/sdk/nginx/azure-mgmt-nginx/generated_samples/api_keys_get.py b/sdk/nginx/azure-mgmt-nginx/generated_samples/api_keys_get.py index e43c55ad8a65..505090e62a08 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_samples/api_keys_get.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_samples/api_keys_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/ApiKeys_Get.json +# x-ms-original-file: specification/nginx/resource-manager/Nginx.NginxPlus/preview/2025-03-01-preview/examples/ApiKeys_Get.json if __name__ == "__main__": main() diff --git a/sdk/nginx/azure-mgmt-nginx/generated_samples/api_keys_list.py b/sdk/nginx/azure-mgmt-nginx/generated_samples/api_keys_list.py index 14656db6c4f5..8f55d4bd9f78 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_samples/api_keys_list.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_samples/api_keys_list.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/ApiKeys_List.json +# x-ms-original-file: specification/nginx/resource-manager/Nginx.NginxPlus/preview/2025-03-01-preview/examples/ApiKeys_List.json if __name__ == "__main__": main() diff --git a/sdk/nginx/azure-mgmt-nginx/generated_samples/certificates_create_or_update.py b/sdk/nginx/azure-mgmt-nginx/generated_samples/certificates_create_or_update.py index dc033d4bbd8e..4e979611e642 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_samples/certificates_create_or_update.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_samples/certificates_create_or_update.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Certificates_CreateOrUpdate.json +# x-ms-original-file: specification/nginx/resource-manager/Nginx.NginxPlus/preview/2025-03-01-preview/examples/Certificates_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/nginx/azure-mgmt-nginx/generated_samples/certificates_delete.py b/sdk/nginx/azure-mgmt-nginx/generated_samples/certificates_delete.py index d1d1400bdd09..f40ac32313c9 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_samples/certificates_delete.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_samples/certificates_delete.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Certificates_Delete.json +# x-ms-original-file: specification/nginx/resource-manager/Nginx.NginxPlus/preview/2025-03-01-preview/examples/Certificates_Delete.json if __name__ == "__main__": main() diff --git a/sdk/nginx/azure-mgmt-nginx/generated_samples/certificates_get.py b/sdk/nginx/azure-mgmt-nginx/generated_samples/certificates_get.py index f3a32df1144f..7937b5d19742 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_samples/certificates_get.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_samples/certificates_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Certificates_Get.json +# x-ms-original-file: specification/nginx/resource-manager/Nginx.NginxPlus/preview/2025-03-01-preview/examples/Certificates_Get.json if __name__ == "__main__": main() diff --git a/sdk/nginx/azure-mgmt-nginx/generated_samples/certificates_list.py b/sdk/nginx/azure-mgmt-nginx/generated_samples/certificates_list.py index e6be437650f1..abf7fcdd314c 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_samples/certificates_list.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_samples/certificates_list.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Certificates_List.json +# x-ms-original-file: specification/nginx/resource-manager/Nginx.NginxPlus/preview/2025-03-01-preview/examples/Certificates_List.json if __name__ == "__main__": main() diff --git a/sdk/nginx/azure-mgmt-nginx/generated_samples/configurations_analysis.py b/sdk/nginx/azure-mgmt-nginx/generated_samples/configurations_analysis.py index a3ccb680adc2..ae6d6875131e 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_samples/configurations_analysis.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_samples/configurations_analysis.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Configurations_Analysis.json +# x-ms-original-file: specification/nginx/resource-manager/Nginx.NginxPlus/preview/2025-03-01-preview/examples/Configurations_Analysis.json if __name__ == "__main__": main() diff --git a/sdk/nginx/azure-mgmt-nginx/generated_samples/configurations_create_or_update.py b/sdk/nginx/azure-mgmt-nginx/generated_samples/configurations_create_or_update.py index 1f487c964cd6..8bc7a8aa4bd3 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_samples/configurations_create_or_update.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_samples/configurations_create_or_update.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Configurations_CreateOrUpdate.json +# x-ms-original-file: specification/nginx/resource-manager/Nginx.NginxPlus/preview/2025-03-01-preview/examples/Configurations_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/nginx/azure-mgmt-nginx/generated_samples/configurations_delete.py b/sdk/nginx/azure-mgmt-nginx/generated_samples/configurations_delete.py index d71ddae41f25..6c723037acbb 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_samples/configurations_delete.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_samples/configurations_delete.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Configurations_Delete.json +# x-ms-original-file: specification/nginx/resource-manager/Nginx.NginxPlus/preview/2025-03-01-preview/examples/Configurations_Delete.json if __name__ == "__main__": main() diff --git a/sdk/nginx/azure-mgmt-nginx/generated_samples/configurations_get.py b/sdk/nginx/azure-mgmt-nginx/generated_samples/configurations_get.py index cac35ab11b6d..f0b39bcb9a43 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_samples/configurations_get.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_samples/configurations_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Configurations_Get.json +# x-ms-original-file: specification/nginx/resource-manager/Nginx.NginxPlus/preview/2025-03-01-preview/examples/Configurations_Get.json if __name__ == "__main__": main() diff --git a/sdk/nginx/azure-mgmt-nginx/generated_samples/configurations_list.py b/sdk/nginx/azure-mgmt-nginx/generated_samples/configurations_list.py index 7093aad43cab..c02723cf2c24 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_samples/configurations_list.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_samples/configurations_list.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Configurations_List.json +# x-ms-original-file: specification/nginx/resource-manager/Nginx.NginxPlus/preview/2025-03-01-preview/examples/Configurations_List.json if __name__ == "__main__": main() diff --git a/sdk/nginx/azure-mgmt-nginx/generated_samples/default_waf_policy_list.py b/sdk/nginx/azure-mgmt-nginx/generated_samples/default_waf_policy_list.py new file mode 100644 index 000000000000..aad130ec13ae --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/generated_samples/default_waf_policy_list.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.nginx import NginxManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-nginx +# USAGE + python default_waf_policy_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = NginxManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.default_waf_policy.list( + resource_group_name="myResourceGroup", + deployment_name="myDeployment", + ) + print(response) + + +# x-ms-original-file: specification/nginx/resource-manager/Nginx.NginxPlus/preview/2025-03-01-preview/examples/DefaultWafPolicy_List.json +if __name__ == "__main__": + main() diff --git a/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_create.py b/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_create.py index 3ddba130d6c7..1453b479f25c 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_create.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_create.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Deployments_Create.json +# x-ms-original-file: specification/nginx/resource-manager/Nginx.NginxPlus/preview/2025-03-01-preview/examples/Deployments_Create.json if __name__ == "__main__": main() diff --git a/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_delete.py b/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_delete.py index b024fdf29d3b..7a71c666a911 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_delete.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_delete.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Deployments_Delete.json +# x-ms-original-file: specification/nginx/resource-manager/Nginx.NginxPlus/preview/2025-03-01-preview/examples/Deployments_Delete.json if __name__ == "__main__": main() diff --git a/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_get.py b/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_get.py index 4158a22fd119..4d96b8eb7510 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_get.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Deployments_Get.json +# x-ms-original-file: specification/nginx/resource-manager/Nginx.NginxPlus/preview/2025-03-01-preview/examples/Deployments_Get.json if __name__ == "__main__": main() diff --git a/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_get_auto_scale.py b/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_get_auto_scale.py index 8920a0811d56..a14a64f677c1 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_get_auto_scale.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_get_auto_scale.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Deployments_Get_AutoScale.json +# x-ms-original-file: specification/nginx/resource-manager/Nginx.NginxPlus/preview/2025-03-01-preview/examples/Deployments_Get_AutoScale.json if __name__ == "__main__": main() diff --git a/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_list.py b/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_list.py index 6236b8df9a3f..5ec44891b6e0 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_list.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_list.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -35,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Deployments_List.json +# x-ms-original-file: specification/nginx/resource-manager/Nginx.NginxPlus/preview/2025-03-01-preview/examples/Deployments_List.json if __name__ == "__main__": main() diff --git a/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_list_by_resource_group.py b/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_list_by_resource_group.py index a56ae5afd178..8cf8ccbfb61d 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_list_by_resource_group.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_list_by_resource_group.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Deployments_ListByResourceGroup.json +# x-ms-original-file: specification/nginx/resource-manager/Nginx.NginxPlus/preview/2025-03-01-preview/examples/Deployments_ListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_update.py b/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_update.py index 34925bd37cc8..89ea4f1727d3 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_update.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_update.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Deployments_Update.json +# x-ms-original-file: specification/nginx/resource-manager/Nginx.NginxPlus/preview/2025-03-01-preview/examples/Deployments_Update.json if __name__ == "__main__": main() diff --git a/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_update_subnet.py b/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_update_subnet.py index 7b595c70ddb7..b5c46caa9782 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_update_subnet.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_samples/deployments_update_subnet.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Deployments_UpdateSubnet.json +# x-ms-original-file: specification/nginx/resource-manager/Nginx.NginxPlus/preview/2025-03-01-preview/examples/Deployments_UpdateSubnet.json if __name__ == "__main__": main() diff --git a/sdk/nginx/azure-mgmt-nginx/generated_samples/operations_list.py b/sdk/nginx/azure-mgmt-nginx/generated_samples/operations_list.py index e22445325bcc..0459cb920704 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_samples/operations_list.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_samples/operations_list.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -35,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Operations_List.json +# x-ms-original-file: specification/nginx/resource-manager/Nginx.NginxPlus/preview/2025-03-01-preview/examples/Operations_List.json if __name__ == "__main__": main() diff --git a/sdk/nginx/azure-mgmt-nginx/generated_samples/waf_policy_create.py b/sdk/nginx/azure-mgmt-nginx/generated_samples/waf_policy_create.py new file mode 100644 index 000000000000..7fb081d3f8de --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/generated_samples/waf_policy_create.py @@ -0,0 +1,44 @@ +# pylint: disable=line-too-long,useless-suppression +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.nginx import NginxManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-nginx +# USAGE + python waf_policy_create.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = NginxManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.waf_policy.begin_create( + resource_group_name="myResourceGroup", + deployment_name="myDeployment", + waf_policy_name="myWafPolicy", + ).result() + print(response) + + +# x-ms-original-file: specification/nginx/resource-manager/Nginx.NginxPlus/preview/2025-03-01-preview/examples/WafPolicy_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/nginx/azure-mgmt-nginx/generated_samples/waf_policy_delete.py b/sdk/nginx/azure-mgmt-nginx/generated_samples/waf_policy_delete.py new file mode 100644 index 000000000000..f18c0efd87ec --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/generated_samples/waf_policy_delete.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.nginx import NginxManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-nginx +# USAGE + python waf_policy_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = NginxManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.waf_policy.begin_delete( + resource_group_name="myResourceGroup", + deployment_name="myDeployment", + waf_policy_name="myWafPolicy", + ).result() + + +# x-ms-original-file: specification/nginx/resource-manager/Nginx.NginxPlus/preview/2025-03-01-preview/examples/WafPolicy_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/nginx/azure-mgmt-nginx/generated_samples/waf_policy_get.py b/sdk/nginx/azure-mgmt-nginx/generated_samples/waf_policy_get.py new file mode 100644 index 000000000000..0b07e9ba97ca --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/generated_samples/waf_policy_get.py @@ -0,0 +1,44 @@ +# pylint: disable=line-too-long,useless-suppression +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.nginx import NginxManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-nginx +# USAGE + python waf_policy_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = NginxManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.waf_policy.get( + resource_group_name="myResourceGroup", + deployment_name="myDeployment", + waf_policy_name="myWafPolicy", + ) + print(response) + + +# x-ms-original-file: specification/nginx/resource-manager/Nginx.NginxPlus/preview/2025-03-01-preview/examples/WafPolicy_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/nginx/azure-mgmt-nginx/generated_samples/waf_policy_list.py b/sdk/nginx/azure-mgmt-nginx/generated_samples/waf_policy_list.py new file mode 100644 index 000000000000..87a6ba9a543a --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/generated_samples/waf_policy_list.py @@ -0,0 +1,44 @@ +# pylint: disable=line-too-long,useless-suppression +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.nginx import NginxManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-nginx +# USAGE + python waf_policy_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = NginxManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.waf_policy.list( + resource_group_name="myResourceGroup", + deployment_name="myDeployment", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/nginx/resource-manager/Nginx.NginxPlus/preview/2025-03-01-preview/examples/WafPolicy_List.json +if __name__ == "__main__": + main() diff --git a/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_api_keys_operations.py b/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_api_keys_operations.py index 778d8cb65fef..77b16d11b36e 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_api_keys_operations.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_api_keys_operations.py @@ -20,25 +20,24 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_keys_create_or_update(self, resource_group): - response = self.client.api_keys.create_or_update( + def test_api_keys_list(self, resource_group): + response = self.client.api_keys.list( resource_group_name=resource_group.name, deployment_name="str", - api_key_name="str", - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_keys_delete(self, resource_group): - response = self.client.api_keys.delete( + def test_api_keys_get(self, resource_group): + response = self.client.api_keys.get( resource_group_name=resource_group.name, deployment_name="str", api_key_name="str", - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ) # please add some check logic here by yourself @@ -46,12 +45,12 @@ def test_api_keys_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_keys_get(self, resource_group): - response = self.client.api_keys.get( + def test_api_keys_create_or_update(self, resource_group): + response = self.client.api_keys.create_or_update( resource_group_name=resource_group.name, deployment_name="str", api_key_name="str", - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ) # please add some check logic here by yourself @@ -59,12 +58,13 @@ def test_api_keys_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_keys_list(self, resource_group): - response = self.client.api_keys.list( + def test_api_keys_delete(self, resource_group): + response = self.client.api_keys.delete( resource_group_name=resource_group.name, deployment_name="str", - api_version="2024-11-01-preview", + api_key_name="str", + api_version="2025-03-01-preview", ) - result = [r for r in response] + # please add some check logic here by yourself # ... diff --git a/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_api_keys_operations_async.py b/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_api_keys_operations_async.py index bd3935178b67..7bbc760f5e16 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_api_keys_operations_async.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_api_keys_operations_async.py @@ -21,25 +21,24 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_keys_create_or_update(self, resource_group): - response = await self.client.api_keys.create_or_update( + async def test_api_keys_list(self, resource_group): + response = self.client.api_keys.list( resource_group_name=resource_group.name, deployment_name="str", - api_key_name="str", - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_keys_delete(self, resource_group): - response = await self.client.api_keys.delete( + async def test_api_keys_get(self, resource_group): + response = await self.client.api_keys.get( resource_group_name=resource_group.name, deployment_name="str", api_key_name="str", - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ) # please add some check logic here by yourself @@ -47,12 +46,12 @@ async def test_api_keys_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_keys_get(self, resource_group): - response = await self.client.api_keys.get( + async def test_api_keys_create_or_update(self, resource_group): + response = await self.client.api_keys.create_or_update( resource_group_name=resource_group.name, deployment_name="str", api_key_name="str", - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ) # please add some check logic here by yourself @@ -60,12 +59,13 @@ async def test_api_keys_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_keys_list(self, resource_group): - response = self.client.api_keys.list( + async def test_api_keys_delete(self, resource_group): + response = await self.client.api_keys.delete( resource_group_name=resource_group.name, deployment_name="str", - api_version="2024-11-01-preview", + api_key_name="str", + api_version="2025-03-01-preview", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... diff --git a/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_certificates_operations.py b/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_certificates_operations.py index 9015537ef366..6e5a9399aa1f 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_certificates_operations.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_certificates_operations.py @@ -18,6 +18,18 @@ class TestNginxManagementCertificatesOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(NginxManagementClient) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_certificates_list(self, resource_group): + response = self.client.certificates.list( + resource_group_name=resource_group.name, + deployment_name="str", + api_version="2025-03-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_certificates_get(self, resource_group): @@ -25,7 +37,7 @@ def test_certificates_get(self, resource_group): resource_group_name=resource_group.name, deployment_name="str", certificate_name="str", - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ) # please add some check logic here by yourself @@ -38,7 +50,7 @@ def test_certificates_begin_create_or_update(self, resource_group): resource_group_name=resource_group.name, deployment_name="str", certificate_name="str", - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -51,20 +63,8 @@ def test_certificates_begin_delete(self, resource_group): resource_group_name=resource_group.name, deployment_name="str", certificate_name="str", - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_certificates_list(self, resource_group): - response = self.client.certificates.list( - resource_group_name=resource_group.name, - deployment_name="str", - api_version="2024-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_certificates_operations_async.py b/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_certificates_operations_async.py index 31377bb30174..04511bfce680 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_certificates_operations_async.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_certificates_operations_async.py @@ -19,6 +19,18 @@ class TestNginxManagementCertificatesOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(NginxManagementClient, is_async=True) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_certificates_list(self, resource_group): + response = self.client.certificates.list( + resource_group_name=resource_group.name, + deployment_name="str", + api_version="2025-03-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_certificates_get(self, resource_group): @@ -26,7 +38,7 @@ async def test_certificates_get(self, resource_group): resource_group_name=resource_group.name, deployment_name="str", certificate_name="str", - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ) # please add some check logic here by yourself @@ -40,7 +52,7 @@ async def test_certificates_begin_create_or_update(self, resource_group): resource_group_name=resource_group.name, deployment_name="str", certificate_name="str", - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -55,21 +67,9 @@ async def test_certificates_begin_delete(self, resource_group): resource_group_name=resource_group.name, deployment_name="str", certificate_name="str", - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_certificates_list(self, resource_group): - response = self.client.certificates.list( - resource_group_name=resource_group.name, - deployment_name="str", - api_version="2024-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_configurations_operations.py b/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_configurations_operations.py index 77da242df523..382badb8f461 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_configurations_operations.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_configurations_operations.py @@ -24,7 +24,7 @@ def test_configurations_list(self, resource_group): response = self.client.configurations.list( resource_group_name=resource_group.name, deployment_name="str", - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ) result = [r for r in response] # please add some check logic here by yourself @@ -37,7 +37,7 @@ def test_configurations_get(self, resource_group): resource_group_name=resource_group.name, deployment_name="str", configuration_name="str", - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ) # please add some check logic here by yourself @@ -50,7 +50,7 @@ def test_configurations_begin_create_or_update(self, resource_group): resource_group_name=resource_group.name, deployment_name="str", configuration_name="str", - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -63,7 +63,7 @@ def test_configurations_begin_delete(self, resource_group): resource_group_name=resource_group.name, deployment_name="str", configuration_name="str", - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -76,7 +76,7 @@ def test_configurations_analysis(self, resource_group): resource_group_name=resource_group.name, deployment_name="str", configuration_name="str", - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_configurations_operations_async.py b/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_configurations_operations_async.py index 20ceda6c70e3..35de9d3b7a68 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_configurations_operations_async.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_configurations_operations_async.py @@ -25,7 +25,7 @@ async def test_configurations_list(self, resource_group): response = self.client.configurations.list( resource_group_name=resource_group.name, deployment_name="str", - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself @@ -38,7 +38,7 @@ async def test_configurations_get(self, resource_group): resource_group_name=resource_group.name, deployment_name="str", configuration_name="str", - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ) # please add some check logic here by yourself @@ -52,7 +52,7 @@ async def test_configurations_begin_create_or_update(self, resource_group): resource_group_name=resource_group.name, deployment_name="str", configuration_name="str", - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -67,7 +67,7 @@ async def test_configurations_begin_delete(self, resource_group): resource_group_name=resource_group.name, deployment_name="str", configuration_name="str", - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -81,7 +81,7 @@ async def test_configurations_analysis(self, resource_group): resource_group_name=resource_group.name, deployment_name="str", configuration_name="str", - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_default_waf_policy_operations.py b/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_default_waf_policy_operations.py new file mode 100644 index 000000000000..ab93df2d7ac5 --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_default_waf_policy_operations.py @@ -0,0 +1,31 @@ +# 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 pytest +from azure.mgmt.nginx import NginxManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestNginxManagementDefaultWafPolicyOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(NginxManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_default_waf_policy_list(self, resource_group): + response = self.client.default_waf_policy.list( + resource_group_name=resource_group.name, + deployment_name="str", + api_version="2025-03-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_default_waf_policy_operations_async.py b/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_default_waf_policy_operations_async.py new file mode 100644 index 000000000000..6e85aa5bcd1c --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_default_waf_policy_operations_async.py @@ -0,0 +1,32 @@ +# 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 pytest +from azure.mgmt.nginx.aio import NginxManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestNginxManagementDefaultWafPolicyOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(NginxManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_default_waf_policy_list(self, resource_group): + response = await self.client.default_waf_policy.list( + resource_group_name=resource_group.name, + deployment_name="str", + api_version="2025-03-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_deployments_operations.py b/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_deployments_operations.py index 0dbecf943803..e654c35a5ca1 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_deployments_operations.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_deployments_operations.py @@ -18,13 +18,34 @@ class TestNginxManagementDeploymentsOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(NginxManagementClient) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_deployments_list(self, resource_group): + response = self.client.deployments.list( + api_version="2025-03-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_deployments_list_by_resource_group(self, resource_group): + response = self.client.deployments.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2025-03-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_deployments_get(self, resource_group): response = self.client.deployments.get( resource_group_name=resource_group.name, deployment_name="str", - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ) # please add some check logic here by yourself @@ -36,7 +57,7 @@ def test_deployments_begin_create_or_update(self, resource_group): response = self.client.deployments.begin_create_or_update( resource_group_name=resource_group.name, deployment_name="str", - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -48,7 +69,7 @@ def test_deployments_begin_update(self, resource_group): response = self.client.deployments.begin_update( resource_group_name=resource_group.name, deployment_name="str", - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -60,29 +81,8 @@ def test_deployments_begin_delete(self, resource_group): response = self.client.deployments.begin_delete( resource_group_name=resource_group.name, deployment_name="str", - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_deployments_list(self, resource_group): - response = self.client.deployments.list( - api_version="2024-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_deployments_list_by_resource_group(self, resource_group): - response = self.client.deployments.list_by_resource_group( - resource_group_name=resource_group.name, - api_version="2024-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_deployments_operations_async.py b/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_deployments_operations_async.py index 337809d16e8a..4b63c4e81785 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_deployments_operations_async.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_deployments_operations_async.py @@ -19,13 +19,34 @@ class TestNginxManagementDeploymentsOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(NginxManagementClient, is_async=True) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_deployments_list(self, resource_group): + response = self.client.deployments.list( + api_version="2025-03-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_deployments_list_by_resource_group(self, resource_group): + response = self.client.deployments.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2025-03-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_deployments_get(self, resource_group): response = await self.client.deployments.get( resource_group_name=resource_group.name, deployment_name="str", - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ) # please add some check logic here by yourself @@ -38,7 +59,7 @@ async def test_deployments_begin_create_or_update(self, resource_group): await self.client.deployments.begin_create_or_update( resource_group_name=resource_group.name, deployment_name="str", - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -52,7 +73,7 @@ async def test_deployments_begin_update(self, resource_group): await self.client.deployments.begin_update( resource_group_name=resource_group.name, deployment_name="str", - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -66,30 +87,9 @@ async def test_deployments_begin_delete(self, resource_group): await self.client.deployments.begin_delete( resource_group_name=resource_group.name, deployment_name="str", - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_deployments_list(self, resource_group): - response = self.client.deployments.list( - api_version="2024-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_deployments_list_by_resource_group(self, resource_group): - response = self.client.deployments.list_by_resource_group( - resource_group_name=resource_group.name, - api_version="2024-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_operations.py b/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_operations.py index 0bd6d31cfba8..eb04a81419b0 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_operations.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_operations.py @@ -22,7 +22,7 @@ def setup_method(self, method): @recorded_by_proxy def test_operations_list(self, resource_group): response = self.client.operations.list( - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_operations_async.py b/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_operations_async.py index 8f0c573e997a..5acab908bbf1 100644 --- a/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_operations_async.py +++ b/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_operations_async.py @@ -23,7 +23,7 @@ def setup_method(self, method): @recorded_by_proxy_async async def test_operations_list(self, resource_group): response = self.client.operations.list( - api_version="2024-11-01-preview", + api_version="2025-03-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_waf_policy_operations.py b/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_waf_policy_operations.py new file mode 100644 index 000000000000..e660f38d9561 --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_waf_policy_operations.py @@ -0,0 +1,70 @@ +# 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 pytest +from azure.mgmt.nginx import NginxManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestNginxManagementWafPolicyOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(NginxManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_waf_policy_list(self, resource_group): + response = self.client.waf_policy.list( + resource_group_name=resource_group.name, + deployment_name="str", + api_version="2025-03-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_waf_policy_get(self, resource_group): + response = self.client.waf_policy.get( + resource_group_name=resource_group.name, + deployment_name="str", + waf_policy_name="str", + api_version="2025-03-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_waf_policy_begin_create(self, resource_group): + response = self.client.waf_policy.begin_create( + resource_group_name=resource_group.name, + deployment_name="str", + waf_policy_name="str", + api_version="2025-03-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_waf_policy_begin_delete(self, resource_group): + response = self.client.waf_policy.begin_delete( + resource_group_name=resource_group.name, + deployment_name="str", + waf_policy_name="str", + api_version="2025-03-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_waf_policy_operations_async.py b/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_waf_policy_operations_async.py new file mode 100644 index 000000000000..9935c017ee46 --- /dev/null +++ b/sdk/nginx/azure-mgmt-nginx/generated_tests/test_nginx_management_waf_policy_operations_async.py @@ -0,0 +1,75 @@ +# 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 pytest +from azure.mgmt.nginx.aio import NginxManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestNginxManagementWafPolicyOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(NginxManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_waf_policy_list(self, resource_group): + response = self.client.waf_policy.list( + resource_group_name=resource_group.name, + deployment_name="str", + api_version="2025-03-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_waf_policy_get(self, resource_group): + response = await self.client.waf_policy.get( + resource_group_name=resource_group.name, + deployment_name="str", + waf_policy_name="str", + api_version="2025-03-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_waf_policy_begin_create(self, resource_group): + response = await ( + await self.client.waf_policy.begin_create( + resource_group_name=resource_group.name, + deployment_name="str", + waf_policy_name="str", + api_version="2025-03-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_waf_policy_begin_delete(self, resource_group): + response = await ( + await self.client.waf_policy.begin_delete( + resource_group_name=resource_group.name, + deployment_name="str", + waf_policy_name="str", + api_version="2025-03-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/nginx/azure-mgmt-nginx/pyproject.toml b/sdk/nginx/azure-mgmt-nginx/pyproject.toml index 540da07d41af..7a685366f825 100644 --- a/sdk/nginx/azure-mgmt-nginx/pyproject.toml +++ b/sdk/nginx/azure-mgmt-nginx/pyproject.toml @@ -1,6 +1,88 @@ +[build-system] +requires = [ + "setuptools>=77.0.3", + "wheel", +] +build-backend = "setuptools.build_meta" + +[project] +name = "azure-mgmt-nginx" +authors = [ + { name = "Microsoft Corporation", email = "azpysdkhelp@microsoft.com" }, +] +description = "Microsoft Azure Nginx Management Client Library for Python" +license = "MIT" +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +requires-python = ">=3.9" +keywords = [ + "azure", + "azure sdk", +] +dependencies = [ + "msrest>=0.7.1", + "azure-mgmt-core>=1.6.0", + "typing-extensions>=4.6.0", +] +dynamic = [ + "version", + "readme", +] + +[project.urls] +repository = "https://github.com/Azure/azure-sdk-for-python" + +[tool.setuptools.dynamic.version] +attr = "azure.mgmt.nginx._version.VERSION" + +[tool.setuptools.dynamic.readme] +file = [ + "README.md", + "CHANGELOG.md", +] +content-type = "text/markdown" + +[tool.setuptools.packages.find] +exclude = [ + "tests*", + "generated_tests*", + "samples*", + "generated_samples*", + "doc*", + "azure", + "azure.mgmt", +] + +[tool.setuptools.package-data] +pytyped = [ + "py.typed", +] + [tool.azure-sdk-build] breaking = false mypy = false pyright = false type_check_samples = false verifytypes = false + +[packaging] +package_name = "azure-mgmt-nginx" +package_nspkg = "azure-mgmt-nspkg" +package_pprint_name = "Nginx Management" +package_doc_id = "" +is_stable = false +is_arm = true +need_msrestazure = false +need_azuremgmtcore = true +title = "NginxManagementClient" +sample_link = "https://github.com/nginxinc/nginxaas-for-azure-snippets/tree/main/sdk/python" +exclude_folders = "" diff --git a/sdk/nginx/azure-mgmt-nginx/sdk_packaging.toml b/sdk/nginx/azure-mgmt-nginx/sdk_packaging.toml deleted file mode 100644 index 077709fda12d..000000000000 --- a/sdk/nginx/azure-mgmt-nginx/sdk_packaging.toml +++ /dev/null @@ -1,11 +0,0 @@ -[packaging] -package_name = "azure-mgmt-nginx" -package_nspkg = "azure-mgmt-nspkg" -package_pprint_name = "Nginx Management" -package_doc_id = "" -is_stable = false -is_arm = true -need_msrestazure = false -need_azuremgmtcore = true -title = "NginxManagementClient" -sample_link = "https://github.com/nginxinc/nginxaas-for-azure-snippets/tree/main/sdk/python" diff --git a/sdk/nginx/azure-mgmt-nginx/setup.py b/sdk/nginx/azure-mgmt-nginx/setup.py deleted file mode 100644 index 4c971572f69c..000000000000 --- a/sdk/nginx/azure-mgmt-nginx/setup.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env python - -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- - -import re -import os.path -from io import open -from setuptools import find_packages, setup - -# Change the PACKAGE_NAME only to change folder and different name -PACKAGE_NAME = "azure-mgmt-nginx" -PACKAGE_PPRINT_NAME = "Nginx Management" - -# a-b-c => a/b/c -package_folder_path = PACKAGE_NAME.replace("-", "/") -# a-b-c => a.b.c -namespace_name = PACKAGE_NAME.replace("-", ".") - -# Version extraction inspired from 'requests' -with open( - os.path.join(package_folder_path, "version.py") - if os.path.exists(os.path.join(package_folder_path, "version.py")) - else os.path.join(package_folder_path, "_version.py"), - "r", -) as fd: - version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) - -if not version: - raise RuntimeError("Cannot find version information") - -with open("README.md", encoding="utf-8") as f: - readme = f.read() -with open("CHANGELOG.md", encoding="utf-8") as f: - changelog = f.read() - -setup( - name=PACKAGE_NAME, - version=version, - description="Microsoft Azure {} Client Library for Python".format(PACKAGE_PPRINT_NAME), - long_description=readme + "\n\n" + changelog, - long_description_content_type="text/markdown", - license="MIT License", - author="Microsoft Corporation", - author_email="azpysdkhelp@microsoft.com", - url="https://github.com/Azure/azure-sdk-for-python", - keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product - classifiers=[ - "Development Status :: 4 - Beta", - "Programming Language :: Python", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "License :: OSI Approved :: MIT License", - ], - zip_safe=False, - packages=find_packages( - exclude=[ - "tests", - # Exclude packages that will be covered by PEP420 or nspkg - "azure", - "azure.mgmt", - ] - ), - include_package_data=True, - package_data={ - "pytyped": ["py.typed"], - }, - install_requires=[ - "isodate>=0.6.1", - "typing-extensions>=4.6.0", - "azure-common>=1.1", - "azure-mgmt-core>=1.3.2", - ], - python_requires=">=3.8", -)