diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/CHANGELOG.md b/sdk/neonpostgres/azure-mgmt-neonpostgres/CHANGELOG.md index 711379066f03..3e27e2084f8d 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/CHANGELOG.md +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/CHANGELOG.md @@ -1,5 +1,30 @@ # Release History +## 2.0.0 (2025-05-06) + +### Breaking Changes + + - Deleted or renamed client operation group `NeonPostgresMgmtClient.models` + - Deleted or renamed method `BranchesOperations.begin_update` + - Deleted or renamed method `ComputesOperations.begin_create_or_update` + - Deleted or renamed method `ComputesOperations.begin_update` + - Deleted or renamed method `ComputesOperations.delete` + - Deleted or renamed method `ComputesOperations.get` + - Deleted or renamed method `EndpointsOperations.begin_create_or_update` + - Deleted or renamed method `EndpointsOperations.begin_update` + - Deleted or renamed method `EndpointsOperations.delete` + - Deleted or renamed method `EndpointsOperations.get` + - Deleted or renamed method `NeonDatabasesOperations.begin_create_or_update` + - Deleted or renamed method `NeonDatabasesOperations.begin_update` + - Deleted or renamed method `NeonDatabasesOperations.delete` + - Deleted or renamed method `NeonDatabasesOperations.get` + - Deleted or renamed method `NeonRolesOperations.begin_create_or_update` + - Deleted or renamed method `NeonRolesOperations.begin_update` + - Deleted or renamed method `NeonRolesOperations.delete` + - Deleted or renamed method `NeonRolesOperations.get` + - Deleted or renamed method `ProjectsOperations.begin_update` + - Deleted or renamed model `ModelsOperations` + ## 1.0.0 (2025-04-21) ### Features Added diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/README.md b/sdk/neonpostgres/azure-mgmt-neonpostgres/README.md index 46b4ed1ef6f0..c3486515a5d9 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/README.md +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Neonpostgres 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 diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/_meta.json b/sdk/neonpostgres/azure-mgmt-neonpostgres/_meta.json index 6a1c89084169..de499d796a46 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/_meta.json +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/_meta.json @@ -1,6 +1,6 @@ { - "commit": "917ba27f78348899fba4cafb37fcf018f1987a8e", + "commit": "9990ef08cbc4199a0ebea96403a23de493df11d7", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "typespec_src": "specification/liftrneon/Neon.Postgres.Management", - "@azure-tools/typespec-python": "0.42.2" + "@azure-tools/typespec-python": "0.44.1" } \ No newline at end of file diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/apiview-properties.json b/sdk/neonpostgres/azure-mgmt-neonpostgres/apiview-properties.json index 33dfad20b8a1..3a05f83a0376 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/apiview-properties.json +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/apiview-properties.json @@ -1,26 +1,26 @@ { "CrossLanguagePackageId": "Neon.Postgres", "CrossLanguageDefinitionId": { - "azure.mgmt.neonpostgres.models.Attributes": "Neon.Postgres.Models.Attributes", + "azure.mgmt.neonpostgres.models.Attributes": "Neon.Postgres.Attributes", "azure.mgmt.neonpostgres.models.Resource": "Azure.ResourceManager.CommonTypes.Resource", "azure.mgmt.neonpostgres.models.ProxyResource": "Azure.ResourceManager.CommonTypes.ProxyResource", "azure.mgmt.neonpostgres.models.Branch": "Neon.Postgres.Branch", - "azure.mgmt.neonpostgres.models.BranchProperties": "Neon.Postgres.Models.BranchProperties", + "azure.mgmt.neonpostgres.models.BranchProperties": "Neon.Postgres.BranchProperties", "azure.mgmt.neonpostgres.models.CompanyDetails": "LiftrBase.CompanyDetails", "azure.mgmt.neonpostgres.models.Compute": "Neon.Postgres.Compute", - "azure.mgmt.neonpostgres.models.ComputeProperties": "Neon.Postgres.Models.ComputeProperties", - "azure.mgmt.neonpostgres.models.ConnectionUriProperties": "Neon.Postgres.Models.ConnectionUriProperties", - "azure.mgmt.neonpostgres.models.DefaultEndpointSettings": "Neon.Postgres.Models.DefaultEndpointSettings", + "azure.mgmt.neonpostgres.models.ComputeProperties": "Neon.Postgres.ComputeProperties", + "azure.mgmt.neonpostgres.models.ConnectionUriProperties": "Neon.Postgres.ConnectionUriProperties", + "azure.mgmt.neonpostgres.models.DefaultEndpointSettings": "Neon.Postgres.DefaultEndpointSettings", "azure.mgmt.neonpostgres.models.Endpoint": "Neon.Postgres.Endpoint", - "azure.mgmt.neonpostgres.models.EndpointProperties": "Neon.Postgres.Models.EndpointProperties", + "azure.mgmt.neonpostgres.models.EndpointProperties": "Neon.Postgres.EndpointProperties", "azure.mgmt.neonpostgres.models.ErrorAdditionalInfo": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo", "azure.mgmt.neonpostgres.models.ErrorDetail": "Azure.ResourceManager.CommonTypes.ErrorDetail", "azure.mgmt.neonpostgres.models.ErrorResponse": "Azure.ResourceManager.CommonTypes.ErrorResponse", "azure.mgmt.neonpostgres.models.MarketplaceDetails": "LiftrBase.MarketplaceDetails", "azure.mgmt.neonpostgres.models.NeonDatabase": "Neon.Postgres.NeonDatabase", - "azure.mgmt.neonpostgres.models.NeonDatabaseProperties": "Neon.Postgres.Models.NeonDatabaseProperties", + "azure.mgmt.neonpostgres.models.NeonDatabaseProperties": "Neon.Postgres.NeonDatabaseProperties", "azure.mgmt.neonpostgres.models.NeonRole": "Neon.Postgres.NeonRole", - "azure.mgmt.neonpostgres.models.NeonRoleProperties": "Neon.Postgres.Models.NeonRoleProperties", + "azure.mgmt.neonpostgres.models.NeonRoleProperties": "Neon.Postgres.NeonRoleProperties", "azure.mgmt.neonpostgres.models.OfferDetails": "LiftrBase.OfferDetails", "azure.mgmt.neonpostgres.models.Operation": "Azure.ResourceManager.CommonTypes.Operation", "azure.mgmt.neonpostgres.models.OperationDisplay": "Azure.ResourceManager.CommonTypes.OperationDisplay", @@ -28,10 +28,10 @@ "azure.mgmt.neonpostgres.models.TrackedResource": "Azure.ResourceManager.CommonTypes.TrackedResource", "azure.mgmt.neonpostgres.models.OrganizationResource": "Neon.Postgres.OrganizationResource", "azure.mgmt.neonpostgres.models.PartnerOrganizationProperties": "LiftrBase.Data.PartnerOrganizationProperties", - "azure.mgmt.neonpostgres.models.PgVersion": "Neon.Postgres.Models.PgVersion", - "azure.mgmt.neonpostgres.models.PgVersionsResult": "Neon.Postgres.Models.PgVersionsResult", + "azure.mgmt.neonpostgres.models.PgVersion": "Neon.Postgres.PgVersion", + "azure.mgmt.neonpostgres.models.PgVersionsResult": "Neon.Postgres.PgVersionsResult", "azure.mgmt.neonpostgres.models.Project": "Neon.Postgres.Project", - "azure.mgmt.neonpostgres.models.ProjectProperties": "Neon.Postgres.Models.ProjectProperties", + "azure.mgmt.neonpostgres.models.ProjectProperties": "Neon.Postgres.ProjectProperties", "azure.mgmt.neonpostgres.models.SingleSignOnProperties": "LiftrBase.SingleSignOnProperties", "azure.mgmt.neonpostgres.models.SystemData": "Azure.ResourceManager.CommonTypes.SystemData", "azure.mgmt.neonpostgres.models.UserDetails": "LiftrBase.UserDetails", @@ -41,45 +41,48 @@ "azure.mgmt.neonpostgres.models.MarketplaceSubscriptionStatus": "LiftrBase.MarketplaceSubscriptionStatus", "azure.mgmt.neonpostgres.models.ResourceProvisioningState": "Azure.ResourceManager.ResourceProvisioningState", "azure.mgmt.neonpostgres.models.SingleSignOnStates": "LiftrBase.SingleSignOnStates", - "azure.mgmt.neonpostgres.models.EndpointType": "Neon.Postgres.Models.EndpointType", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.operations.list": "Azure.ResourceManager.Operations.list", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.organizations.get": "Neon.Postgres.Organizations.get", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.organizations.begin_create_or_update": "Neon.Postgres.Organizations.createOrUpdate", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.organizations.begin_update": "Neon.Postgres.Organizations.update", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.organizations.begin_delete": "Neon.Postgres.Organizations.delete", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.organizations.list_by_resource_group": "Neon.Postgres.Organizations.listByResourceGroup", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.organizations.list_by_subscription": "Neon.Postgres.Organizations.listBySubscription", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.organizations.get_postgres_versions": "Neon.Postgres.Organizations.getPostgresVersions", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.projects.get": "Neon.Postgres.Projects.get", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.projects.begin_create_or_update": "Neon.Postgres.Projects.createOrUpdate", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.projects.begin_update": "Neon.Postgres.Projects.update", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.projects.delete": "Neon.Postgres.Projects.delete", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.projects.list": "Neon.Postgres.Projects.list", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.projects.get_connection_uri": "Neon.Postgres.Projects.getConnectionUri", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.branches.get": "Neon.Postgres.Branches.get", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.branches.begin_create_or_update": "Neon.Postgres.Branches.createOrUpdate", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.branches.begin_update": "Neon.Postgres.Branches.update", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.branches.delete": "Neon.Postgres.Branches.delete", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.branches.list": "Neon.Postgres.Branches.list", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.computes.get": "Neon.Postgres.Computes.get", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.computes.begin_create_or_update": "Neon.Postgres.Computes.createOrUpdate", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.computes.begin_update": "Neon.Postgres.Computes.update", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.computes.delete": "Neon.Postgres.Computes.delete", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.computes.list": "Neon.Postgres.Computes.list", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.neon_databases.get": "Neon.Postgres.NeonDatabases.get", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.neon_databases.begin_create_or_update": "Neon.Postgres.NeonDatabases.createOrUpdate", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.neon_databases.begin_update": "Neon.Postgres.NeonDatabases.update", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.neon_databases.delete": "Neon.Postgres.NeonDatabases.delete", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.neon_databases.list": "Neon.Postgres.NeonDatabases.list", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.neon_roles.get": "Neon.Postgres.NeonRoles.get", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.neon_roles.begin_create_or_update": "Neon.Postgres.NeonRoles.createOrUpdate", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.neon_roles.begin_update": "Neon.Postgres.NeonRoles.update", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.neon_roles.delete": "Neon.Postgres.NeonRoles.delete", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.neon_roles.list": "Neon.Postgres.NeonRoles.list", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.endpoints.get": "Neon.Postgres.Endpoints.get", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.endpoints.begin_create_or_update": "Neon.Postgres.Endpoints.createOrUpdate", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.endpoints.begin_update": "Neon.Postgres.Endpoints.update", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.endpoints.delete": "Neon.Postgres.Endpoints.delete", - "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.endpoints.list": "Neon.Postgres.Endpoints.list" + "azure.mgmt.neonpostgres.models.EndpointType": "Neon.Postgres.EndpointType", + "azure.mgmt.neonpostgres.operations.Operations.list": "Azure.ResourceManager.Operations.list", + "azure.mgmt.neonpostgres.aio.operations.Operations.list": "Azure.ResourceManager.Operations.list", + "azure.mgmt.neonpostgres.operations.OrganizationsOperations.get": "Neon.Postgres.Organizations.get", + "azure.mgmt.neonpostgres.aio.operations.OrganizationsOperations.get": "Neon.Postgres.Organizations.get", + "azure.mgmt.neonpostgres.operations.OrganizationsOperations.begin_create_or_update": "Neon.Postgres.Organizations.createOrUpdate", + "azure.mgmt.neonpostgres.aio.operations.OrganizationsOperations.begin_create_or_update": "Neon.Postgres.Organizations.createOrUpdate", + "azure.mgmt.neonpostgres.operations.OrganizationsOperations.begin_update": "Neon.Postgres.Organizations.update", + "azure.mgmt.neonpostgres.aio.operations.OrganizationsOperations.begin_update": "Neon.Postgres.Organizations.update", + "azure.mgmt.neonpostgres.operations.OrganizationsOperations.begin_delete": "Neon.Postgres.Organizations.delete", + "azure.mgmt.neonpostgres.aio.operations.OrganizationsOperations.begin_delete": "Neon.Postgres.Organizations.delete", + "azure.mgmt.neonpostgres.operations.OrganizationsOperations.list_by_resource_group": "Neon.Postgres.Organizations.listByResourceGroup", + "azure.mgmt.neonpostgres.aio.operations.OrganizationsOperations.list_by_resource_group": "Neon.Postgres.Organizations.listByResourceGroup", + "azure.mgmt.neonpostgres.operations.OrganizationsOperations.list_by_subscription": "Neon.Postgres.Organizations.listBySubscription", + "azure.mgmt.neonpostgres.aio.operations.OrganizationsOperations.list_by_subscription": "Neon.Postgres.Organizations.listBySubscription", + "azure.mgmt.neonpostgres.operations.OrganizationsOperations.get_postgres_versions": "Neon.Postgres.Organizations.getPostgresVersions", + "azure.mgmt.neonpostgres.aio.operations.OrganizationsOperations.get_postgres_versions": "Neon.Postgres.Organizations.getPostgresVersions", + "azure.mgmt.neonpostgres.operations.ProjectsOperations.get": "Neon.Postgres.Projects.get", + "azure.mgmt.neonpostgres.aio.operations.ProjectsOperations.get": "Neon.Postgres.Projects.get", + "azure.mgmt.neonpostgres.operations.ProjectsOperations.begin_create_or_update": "Neon.Postgres.Projects.createOrUpdate", + "azure.mgmt.neonpostgres.aio.operations.ProjectsOperations.begin_create_or_update": "Neon.Postgres.Projects.createOrUpdate", + "azure.mgmt.neonpostgres.operations.ProjectsOperations.delete": "Neon.Postgres.Projects.delete", + "azure.mgmt.neonpostgres.aio.operations.ProjectsOperations.delete": "Neon.Postgres.Projects.delete", + "azure.mgmt.neonpostgres.operations.ProjectsOperations.list": "Neon.Postgres.Projects.list", + "azure.mgmt.neonpostgres.aio.operations.ProjectsOperations.list": "Neon.Postgres.Projects.list", + "azure.mgmt.neonpostgres.operations.ProjectsOperations.get_connection_uri": "Neon.Postgres.Projects.getConnectionUri", + "azure.mgmt.neonpostgres.aio.operations.ProjectsOperations.get_connection_uri": "Neon.Postgres.Projects.getConnectionUri", + "azure.mgmt.neonpostgres.operations.BranchesOperations.get": "Neon.Postgres.Branches.get", + "azure.mgmt.neonpostgres.aio.operations.BranchesOperations.get": "Neon.Postgres.Branches.get", + "azure.mgmt.neonpostgres.operations.BranchesOperations.begin_create_or_update": "Neon.Postgres.Branches.createOrUpdate", + "azure.mgmt.neonpostgres.aio.operations.BranchesOperations.begin_create_or_update": "Neon.Postgres.Branches.createOrUpdate", + "azure.mgmt.neonpostgres.operations.BranchesOperations.delete": "Neon.Postgres.Branches.delete", + "azure.mgmt.neonpostgres.aio.operations.BranchesOperations.delete": "Neon.Postgres.Branches.delete", + "azure.mgmt.neonpostgres.operations.BranchesOperations.list": "Neon.Postgres.Branches.list", + "azure.mgmt.neonpostgres.aio.operations.BranchesOperations.list": "Neon.Postgres.Branches.list", + "azure.mgmt.neonpostgres.operations.ComputesOperations.list": "Neon.Postgres.Computes.list", + "azure.mgmt.neonpostgres.aio.operations.ComputesOperations.list": "Neon.Postgres.Computes.list", + "azure.mgmt.neonpostgres.operations.NeonDatabasesOperations.list": "Neon.Postgres.NeonDatabases.list", + "azure.mgmt.neonpostgres.aio.operations.NeonDatabasesOperations.list": "Neon.Postgres.NeonDatabases.list", + "azure.mgmt.neonpostgres.operations.NeonRolesOperations.list": "Neon.Postgres.NeonRoles.list", + "azure.mgmt.neonpostgres.aio.operations.NeonRolesOperations.list": "Neon.Postgres.NeonRoles.list", + "azure.mgmt.neonpostgres.operations.EndpointsOperations.list": "Neon.Postgres.Endpoints.list", + "azure.mgmt.neonpostgres.aio.operations.EndpointsOperations.list": "Neon.Postgres.Endpoints.list" } } \ No newline at end of file diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_client.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_client.py index 7352f11880dc..041666e4b97f 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_client.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_client.py @@ -7,21 +7,22 @@ # -------------------------------------------------------------------------- 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 ._configuration import NeonPostgresMgmtClientConfiguration -from ._serialization import Deserializer, Serializer +from ._utils.serialization import Deserializer, Serializer from .operations import ( BranchesOperations, ComputesOperations, EndpointsOperations, - ModelsOperations, NeonDatabasesOperations, NeonRolesOperations, Operations, @@ -36,8 +37,6 @@ class NeonPostgresMgmtClient: # pylint: disable=too-many-instance-attributes """NeonPostgresMgmtClient. - :ivar models: ModelsOperations operations - :vartype models: azure.mgmt.neonpostgres.operations.ModelsOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.neonpostgres.operations.Operations :ivar organizations: OrganizationsOperations operations @@ -58,7 +57,7 @@ class NeonPostgresMgmtClient: # pylint: disable=too-many-instance-attributes :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 host. Default value is "https://management.azure.com". + :param base_url: Service host. Default value is None. :type base_url: str :keyword api_version: The API version to use for this operation. Default value is "2025-03-01". Note that overriding this default value may result in unsupported behavior. @@ -68,16 +67,22 @@ class NeonPostgresMgmtClient: # pylint: disable=too-many-instance-attributes """ def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any ) -> None: _endpoint = "{endpoint}" + _cloud = kwargs.pop("cloud_setting", None) 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 = NeonPostgresMgmtClientConfiguration( - credential=credential, subscription_id=subscription_id, base_url=base_url, **kwargs + credential=credential, + subscription_id=subscription_id, + base_url=cast(str, base_url), + credential_scopes=credential_scopes, + **kwargs ) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -96,12 +101,11 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=_endpoint, policies=_policies, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, _endpoint), policies=_policies, **kwargs) self._serialize = Serializer() self._deserialize = Deserializer() self._serialize.client_side_validation = False - self.models = ModelsOperations(self._client, self._config, self._serialize, self._deserialize) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.organizations = OrganizationsOperations(self._client, self._config, self._serialize, self._deserialize) self.projects = ProjectsOperations(self._client, self._config, self._serialize, self._deserialize) diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_utils/__init__.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_utils/__init__.py new file mode 100644 index 000000000000..8026245c2abc --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_model_base.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_utils/model_base.py similarity index 98% rename from sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_model_base.py rename to sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_utils/model_base.py index 065b17f67c46..49d5c7259389 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_model_base.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_utils/model_base.py @@ -22,6 +22,7 @@ from datetime import datetime, date, time, timedelta, timezone from json import JSONEncoder import xml.etree.ElementTree as ET +from collections.abc import MutableMapping from typing_extensions import Self import isodate from azure.core.exceptions import DeserializationError @@ -29,11 +30,6 @@ from azure.core.pipeline import PipelineResponse from azure.core.serialization import _Null -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping - _LOGGER = logging.getLogger(__name__) __all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] @@ -348,7 +344,7 @@ def _get_model(module_name: str, model_name: str): _UNSET = object() -class _MyMutableMapping(MutableMapping[str, typing.Any]): # pylint: disable=unsubscriptable-object +class _MyMutableMapping(MutableMapping[str, typing.Any]): def __init__(self, data: typing.Dict[str, typing.Any]) -> None: self._data = data @@ -408,13 +404,13 @@ def get(self, key: str, default: typing.Any = None) -> typing.Any: return default @typing.overload - def pop(self, key: str) -> typing.Any: ... + def pop(self, key: str) -> typing.Any: ... # pylint: disable=arguments-differ @typing.overload - def pop(self, key: str, default: _T) -> _T: ... + def pop(self, key: str, default: _T) -> _T: ... # pylint: disable=signature-differs @typing.overload - def pop(self, key: str, default: typing.Any) -> typing.Any: ... + def pop(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: """ @@ -444,7 +440,7 @@ def clear(self) -> None: """ self._data.clear() - def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: + def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: # pylint: disable=arguments-differ """ Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs. @@ -455,7 +451,7 @@ def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: def setdefault(self, key: str, default: None = None) -> None: ... @typing.overload - def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... + def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: """ @@ -645,7 +641,7 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: cls._attr_to_rest_field: typing.Dict[str, _RestField] = dict(attr_to_rest_field.items()) cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") - return super().__new__(cls) # pylint: disable=no-value-for-parameter + return super().__new__(cls) def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: for base in cls.__bases__: @@ -681,7 +677,7 @@ def _deserialize(cls, data, exist_discriminators): discriminator_value = data.find(xml_name).text # pyright: ignore else: discriminator_value = data.get(discriminator._rest_name) - mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore + mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore # pylint: disable=no-member return mapped_cls._deserialize(data, exist_discriminators) def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.Any]: diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_serialization.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_utils/serialization.py similarity index 100% rename from sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_serialization.py rename to sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_utils/serialization.py diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_version.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_version.py index 0ec13ea52bbf..8f2350dd3b0c 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_version.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0" +VERSION = "2.0.0" diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/aio/_client.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/aio/_client.py index 98a430bde872..074eedd64146 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/aio/_client.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/aio/_client.py @@ -7,21 +7,22 @@ # -------------------------------------------------------------------------- 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 .._serialization import Deserializer, Serializer +from .._utils.serialization import Deserializer, Serializer from ._configuration import NeonPostgresMgmtClientConfiguration from .operations import ( BranchesOperations, ComputesOperations, EndpointsOperations, - ModelsOperations, NeonDatabasesOperations, NeonRolesOperations, Operations, @@ -36,8 +37,6 @@ class NeonPostgresMgmtClient: # pylint: disable=too-many-instance-attributes """NeonPostgresMgmtClient. - :ivar models: ModelsOperations operations - :vartype models: azure.mgmt.neonpostgres.aio.operations.ModelsOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.neonpostgres.aio.operations.Operations :ivar organizations: OrganizationsOperations operations @@ -58,7 +57,7 @@ class NeonPostgresMgmtClient: # pylint: disable=too-many-instance-attributes :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 host. Default value is "https://management.azure.com". + :param base_url: Service host. Default value is None. :type base_url: str :keyword api_version: The API version to use for this operation. Default value is "2025-03-01". Note that overriding this default value may result in unsupported behavior. @@ -68,16 +67,22 @@ class NeonPostgresMgmtClient: # pylint: disable=too-many-instance-attributes """ def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any ) -> None: _endpoint = "{endpoint}" + _cloud = kwargs.pop("cloud_setting", None) 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 = NeonPostgresMgmtClientConfiguration( - credential=credential, subscription_id=subscription_id, base_url=base_url, **kwargs + credential=credential, + subscription_id=subscription_id, + base_url=cast(str, base_url), + credential_scopes=credential_scopes, + **kwargs ) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -96,12 +101,13 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=_endpoint, policies=_policies, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( + base_url=cast(str, _endpoint), policies=_policies, **kwargs + ) self._serialize = Serializer() self._deserialize = Deserializer() self._serialize.client_side_validation = False - self.models = ModelsOperations(self._client, self._config, self._serialize, self._deserialize) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.organizations = OrganizationsOperations(self._client, self._config, self._serialize, self._deserialize) self.projects = ProjectsOperations(self._client, self._config, self._serialize, self._deserialize) diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/aio/operations/__init__.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/aio/operations/__init__.py index 2828a5d7896d..6e7dd0fed8a3 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/aio/operations/__init__.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/aio/operations/__init__.py @@ -12,7 +12,6 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._operations import ModelsOperations # type: ignore from ._operations import Operations # type: ignore from ._operations import OrganizationsOperations # type: ignore from ._operations import ProjectsOperations # type: ignore @@ -27,7 +26,6 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ - "ModelsOperations", "Operations", "OrganizationsOperations", "ProjectsOperations", diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/aio/operations/_operations.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/aio/operations/_operations.py index b193d5581019..a1fd3013d4c6 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/aio/operations/_operations.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/aio/operations/_operations.py @@ -6,9 +6,9 @@ # Code generated by Microsoft (R) Python 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 json -import sys from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -34,35 +34,18 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize -from ..._serialization import Deserializer, Serializer +from ..._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize +from ..._utils.serialization import Deserializer, Serializer from ..._validation import api_version_validation from ...operations._operations import ( build_branches_create_or_update_request, build_branches_delete_request, build_branches_get_request, build_branches_list_request, - build_branches_update_request, - build_computes_create_or_update_request, - build_computes_delete_request, - build_computes_get_request, build_computes_list_request, - build_computes_update_request, - build_endpoints_create_or_update_request, - build_endpoints_delete_request, - build_endpoints_get_request, build_endpoints_list_request, - build_endpoints_update_request, - build_neon_databases_create_or_update_request, - build_neon_databases_delete_request, - build_neon_databases_get_request, build_neon_databases_list_request, - build_neon_databases_update_request, - build_neon_roles_create_or_update_request, - build_neon_roles_delete_request, - build_neon_roles_get_request, build_neon_roles_list_request, - build_neon_roles_update_request, build_operations_list_request, build_organizations_create_or_update_request, build_organizations_delete_request, @@ -76,35 +59,12 @@ build_projects_get_connection_uri_request, build_projects_get_request, build_projects_list_request, - build_projects_update_request, ) from .._configuration import NeonPostgresMgmtClientConfiguration -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]] -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object - - -class ModelsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.neonpostgres.aio.NeonPostgresMgmtClient`'s - :attr:`models` attribute. - """ - - 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: NeonPostgresMgmtClientConfiguration = 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") +JSON = MutableMapping[str, Any] class Operations: @@ -1594,6 +1554,7 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) + @distributed_trace_async @api_version_validation( method_added_on="2025-03-01-preview", params_added_on={ @@ -1603,19 +1564,24 @@ def get_long_running_output(pipeline_response): "resource_group_name", "organization_name", "project_name", - "content_type", "accept", ] }, ) - async def _update_initial( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - properties: Union[_models.Project, JSON, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: + async def delete(self, resource_group_name: str, organization_name: str, project_name: str, **kwargs: Any) -> None: + """Delete a Project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Neon Organizations resource. Required. + :type organization_name: str + :param project_name: The name of the Project. Required. + :type project_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1624,27 +1590,17 @@ async def _update_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_projects_update_request( + _request = build_projects_delete_request( resource_group_name=resource_group_name, organization_name=organization_name, project_name=project_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -1653,46 +1609,136 @@ async def _update_initial( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = True + _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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = _failsafe_deserialize(_models.ErrorResponse, response.json()) 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")) + if cls: + return cls(pipeline_response, None, {}) # type: ignore - deserialized = response.iter_bytes() + @distributed_trace + @api_version_validation( + method_added_on="2025-03-01-preview", + params_added_on={ + "2025-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "accept", + ] + }, + ) + def list(self, resource_group_name: str, organization_name: str, **kwargs: Any) -> AsyncIterable["_models.Project"]: + """List Project resources by OrganizationResource. - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Neon Organizations resource. Required. + :type organization_name: str + :return: An iterator like instance of Project + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.neonpostgres.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - return deserialized # type: ignore + cls: ClsType[List[_models.Project]] = 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_projects_list_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Project], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) @overload - async def begin_update( + async def get_connection_uri( self, resource_group_name: str, organization_name: str, project_name: str, - properties: _models.Project, + connection_uri_parameters: _models.ConnectionUriProperties, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.Project]: - """Update a Project. + ) -> _models.ConnectionUriProperties: + """Action to retrieve the connection URI for the Neon Database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1701,29 +1747,29 @@ async def begin_update( :type organization_name: str :param project_name: The name of the Project. Required. :type project_name: str - :param properties: The resource properties to be updated. Required. - :type properties: ~azure.mgmt.neonpostgres.models.Project + :param connection_uri_parameters: Additional parameters for retrieving the database connection + URI. Required. + :type connection_uri_parameters: ~azure.mgmt.neonpostgres.models.ConnectionUriProperties :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 Project. The Project is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Project] + :return: ConnectionUriProperties. The ConnectionUriProperties is compatible with MutableMapping + :rtype: ~azure.mgmt.neonpostgres.models.ConnectionUriProperties :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_update( + async def get_connection_uri( self, resource_group_name: str, organization_name: str, project_name: str, - properties: JSON, + connection_uri_parameters: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.Project]: - """Update a Project. + ) -> _models.ConnectionUriProperties: + """Action to retrieve the connection URI for the Neon Database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1732,29 +1778,29 @@ async def begin_update( :type organization_name: str :param project_name: The name of the Project. Required. :type project_name: str - :param properties: The resource properties to be updated. Required. - :type properties: JSON + :param connection_uri_parameters: Additional parameters for retrieving the database connection + URI. Required. + :type connection_uri_parameters: JSON :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 Project. The Project is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Project] + :return: ConnectionUriProperties. The ConnectionUriProperties is compatible with MutableMapping + :rtype: ~azure.mgmt.neonpostgres.models.ConnectionUriProperties :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_update( + async def get_connection_uri( self, resource_group_name: str, organization_name: str, project_name: str, - properties: IO[bytes], + connection_uri_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.Project]: - """Update a Project. + ) -> _models.ConnectionUriProperties: + """Action to retrieve the connection URI for the Neon Database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1763,14 +1809,14 @@ async def begin_update( :type organization_name: str :param project_name: The name of the Project. Required. :type project_name: str - :param properties: The resource properties to be updated. Required. - :type properties: IO[bytes] + :param connection_uri_parameters: Additional parameters for retrieving the database connection + URI. Required. + :type connection_uri_parameters: 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 Project. The Project is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Project] + :return: ConnectionUriProperties. The ConnectionUriProperties is compatible with MutableMapping + :rtype: ~azure.mgmt.neonpostgres.models.ConnectionUriProperties :raises ~azure.core.exceptions.HttpResponseError: """ @@ -1789,15 +1835,15 @@ async def begin_update( ] }, ) - async def begin_update( + async def get_connection_uri( self, resource_group_name: str, organization_name: str, project_name: str, - properties: Union[_models.Project, JSON, IO[bytes]], + connection_uri_parameters: Union[_models.ConnectionUriProperties, JSON, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.Project]: - """Update a Project. + ) -> _models.ConnectionUriProperties: + """Action to retrieve the connection URI for the Neon Database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1806,67 +1852,96 @@ async def begin_update( :type organization_name: str :param project_name: The name of the Project. Required. :type project_name: str - :param properties: The resource properties to be updated. Is one of the following types: - Project, JSON, IO[bytes] Required. - :type properties: ~azure.mgmt.neonpostgres.models.Project or JSON or IO[bytes] - :return: An instance of AsyncLROPoller that returns Project. The Project is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Project] + :param connection_uri_parameters: Additional parameters for retrieving the database connection + URI. Is one of the following types: ConnectionUriProperties, JSON, IO[bytes] Required. + :type connection_uri_parameters: ~azure.mgmt.neonpostgres.models.ConnectionUriProperties or + JSON or IO[bytes] + :return: ConnectionUriProperties. The ConnectionUriProperties is compatible with MutableMapping + :rtype: ~azure.mgmt.neonpostgres.models.ConnectionUriProperties :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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Project] = 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._update_initial( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - properties=properties, - 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) + cls: ClsType[_models.ConnectionUriProperties] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = _deserialize(_models.Project, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + content_type = content_type or "application/json" + _content = None + if isinstance(connection_uri_parameters, (IOBase, bytes)): + _content = connection_uri_parameters + else: + _content = json.dumps(connection_uri_parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _request = build_projects_get_connection_uri_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) path_format_arguments = { "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Project].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Project]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.ConnectionUriProperties, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class BranchesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.neonpostgres.aio.NeonPostgresMgmtClient`'s + :attr:`branches` attribute. + """ + + 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: NeonPostgresMgmtClientConfiguration = 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 @api_version_validation( method_added_on="2025-03-01-preview", @@ -1877,12 +1952,15 @@ def get_long_running_output(pipeline_response): "resource_group_name", "organization_name", "project_name", + "branch_name", "accept", ] }, ) - async def delete(self, resource_group_name: str, organization_name: str, project_name: str, **kwargs: Any) -> None: - """Delete a Project. + async def get( + self, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, **kwargs: Any + ) -> _models.Branch: + """Get a Branch. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1891,8 +1969,10 @@ async def delete(self, resource_group_name: str, organization_name: str, project :type organization_name: str :param project_name: The name of the Project. Required. :type project_name: str - :return: None - :rtype: None + :param branch_name: The name of the Branch. Required. + :type branch_name: str + :return: Branch. The Branch is compatible with MutableMapping + :rtype: ~azure.mgmt.neonpostgres.models.Branch :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1906,12 +1986,13 @@ async def delete(self, resource_group_name: str, organization_name: str, project _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models.Branch] = kwargs.pop("cls", None) - _request = build_projects_delete_request( + _request = build_branches_get_request( resource_group_name=resource_group_name, organization_name=organization_name, project_name=project_name, + branch_name=branch_name, subscription_id=self._config.subscription_id, api_version=self._config.api_version, headers=_headers, @@ -1922,22 +2003,33 @@ async def delete(self, resource_group_name: str, organization_name: str, project } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _stream = kwargs.pop("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, 204]: + if response.status_code not in [200]: + if _stream: + 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Branch, response.json()) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore - @distributed_trace @api_version_validation( method_added_on="2025-03-01-preview", params_added_on={ @@ -1946,27 +2038,22 @@ async def delete(self, resource_group_name: str, organization_name: str, project "subscription_id", "resource_group_name", "organization_name", + "project_name", + "branch_name", + "content_type", "accept", ] }, ) - def list(self, resource_group_name: str, organization_name: str, **kwargs: Any) -> AsyncIterable["_models.Project"]: - """List Project resources by OrganizationResource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :return: An iterator like instance of Project - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.neonpostgres.models.Project] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.Project]] = kwargs.pop("cls", None) - + async def _create_or_update_initial( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + branch_name: str, + resource: Union[_models.Branch, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1975,83 +2062,79 @@ def list(self, resource_group_name: str, organization_name: str, **kwargs: Any) } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _request = build_projects_list_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - 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 - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + content_type = content_type or "application/json" + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - return _request + _request = build_branches_create_or_update_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_name, + branch_name=branch_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Project], deserialized.get("value", [])) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - async def get_next(next_link=None): - _request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) + 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 = pipeline_response.http_response + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.iter_bytes() - return pipeline_response + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return AsyncItemPaged(get_next, extract_data) + return deserialized # type: ignore @overload - async def get_connection_uri( + async def begin_create_or_update( self, resource_group_name: str, organization_name: str, project_name: str, - connection_uri_parameters: _models.ConnectionUriProperties, + branch_name: str, + resource: _models.Branch, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ConnectionUriProperties: - """Action to retrieve the connection URI for the Neon Database. + ) -> AsyncLROPoller[_models.Branch]: + """Create a Branch. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2060,29 +2143,32 @@ async def get_connection_uri( :type organization_name: str :param project_name: The name of the Project. Required. :type project_name: str - :param connection_uri_parameters: Additional parameters for retrieving the database connection - URI. Required. - :type connection_uri_parameters: ~azure.mgmt.neonpostgres.models.ConnectionUriProperties + :param branch_name: The name of the Branch. Required. + :type branch_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.neonpostgres.models.Branch :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: ConnectionUriProperties. The ConnectionUriProperties is compatible with MutableMapping - :rtype: ~azure.mgmt.neonpostgres.models.ConnectionUriProperties + :return: An instance of AsyncLROPoller that returns Branch. The Branch is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Branch] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def get_connection_uri( + async def begin_create_or_update( self, resource_group_name: str, organization_name: str, project_name: str, - connection_uri_parameters: JSON, + branch_name: str, + resource: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ConnectionUriProperties: - """Action to retrieve the connection URI for the Neon Database. + ) -> AsyncLROPoller[_models.Branch]: + """Create a Branch. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2091,29 +2177,32 @@ async def get_connection_uri( :type organization_name: str :param project_name: The name of the Project. Required. :type project_name: str - :param connection_uri_parameters: Additional parameters for retrieving the database connection - URI. Required. - :type connection_uri_parameters: JSON + :param branch_name: The name of the Branch. Required. + :type branch_name: str + :param resource: Resource create parameters. Required. + :type resource: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: ConnectionUriProperties. The ConnectionUriProperties is compatible with MutableMapping - :rtype: ~azure.mgmt.neonpostgres.models.ConnectionUriProperties + :return: An instance of AsyncLROPoller that returns Branch. The Branch is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Branch] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def get_connection_uri( + async def begin_create_or_update( self, resource_group_name: str, organization_name: str, project_name: str, - connection_uri_parameters: IO[bytes], + branch_name: str, + resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ConnectionUriProperties: - """Action to retrieve the connection URI for the Neon Database. + ) -> AsyncLROPoller[_models.Branch]: + """Create a Branch. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2122,14 +2211,16 @@ async def get_connection_uri( :type organization_name: str :param project_name: The name of the Project. Required. :type project_name: str - :param connection_uri_parameters: Additional parameters for retrieving the database connection - URI. Required. - :type connection_uri_parameters: IO[bytes] + :param branch_name: The name of the Branch. Required. + :type branch_name: str + :param resource: Resource create parameters. Required. + :type resource: 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: ConnectionUriProperties. The ConnectionUriProperties is compatible with MutableMapping - :rtype: ~azure.mgmt.neonpostgres.models.ConnectionUriProperties + :return: An instance of AsyncLROPoller that returns Branch. The Branch is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Branch] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -2143,20 +2234,22 @@ async def get_connection_uri( "resource_group_name", "organization_name", "project_name", + "branch_name", "content_type", "accept", ] }, ) - async def get_connection_uri( + async def begin_create_or_update( self, resource_group_name: str, organization_name: str, project_name: str, - connection_uri_parameters: Union[_models.ConnectionUriProperties, JSON, IO[bytes]], + branch_name: str, + resource: Union[_models.Branch, JSON, IO[bytes]], **kwargs: Any - ) -> _models.ConnectionUriProperties: - """Action to retrieve the connection URI for the Neon Database. + ) -> AsyncLROPoller[_models.Branch]: + """Create a Branch. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2165,95 +2258,69 @@ async def get_connection_uri( :type organization_name: str :param project_name: The name of the Project. Required. :type project_name: str - :param connection_uri_parameters: Additional parameters for retrieving the database connection - URI. Is one of the following types: ConnectionUriProperties, JSON, IO[bytes] Required. - :type connection_uri_parameters: ~azure.mgmt.neonpostgres.models.ConnectionUriProperties or - JSON or IO[bytes] - :return: ConnectionUriProperties. The ConnectionUriProperties is compatible with MutableMapping - :rtype: ~azure.mgmt.neonpostgres.models.ConnectionUriProperties + :param branch_name: The name of the Branch. Required. + :type branch_name: str + :param resource: Resource create parameters. Is one of the following types: Branch, JSON, + IO[bytes] Required. + :type resource: ~azure.mgmt.neonpostgres.models.Branch or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Branch. The Branch is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Branch] :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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ConnectionUriProperties] = kwargs.pop("cls", None) + cls: ClsType[_models.Branch] = 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_or_update_initial( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_name, + branch_name=branch_name, + resource=resource, + 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) - content_type = content_type or "application/json" - _content = None - if isinstance(connection_uri_parameters, (IOBase, bytes)): - _content = connection_uri_parameters - else: - _content = json.dumps(connection_uri_parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Branch, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized - _request = build_projects_get_connection_uri_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - subscription_id=self._config.subscription_id, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) path_format_arguments = { "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = kwargs.pop("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]: - if _stream: - 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if _stream: - deserialized = response.iter_bytes() + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: - deserialized = _deserialize(_models.ConnectionUriProperties, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class BranchesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.neonpostgres.aio.NeonPostgresMgmtClient`'s - :attr:`branches` attribute. - """ - - 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: NeonPostgresMgmtClientConfiguration = 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") + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Branch].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Branch]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async @api_version_validation( @@ -2270,10 +2337,10 @@ def __init__(self, *args, **kwargs) -> None: ] }, ) - async def get( + async def delete( self, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, **kwargs: Any - ) -> _models.Branch: - """Get a Branch. + ) -> None: + """Delete a Branch. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2284,8 +2351,8 @@ async def get( :type project_name: str :param branch_name: The name of the Branch. Required. :type branch_name: str - :return: Branch. The Branch is compatible with MutableMapping - :rtype: ~azure.mgmt.neonpostgres.models.Branch + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2299,9 +2366,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.Branch] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_branches_get_request( + _request = build_branches_delete_request( resource_group_name=resource_group_name, organization_name=organization_name, project_name=project_name, @@ -2316,33 +2383,22 @@ async def get( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _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]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.Branch, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore + @distributed_trace @api_version_validation( method_added_on="2025-03-01-preview", params_added_on={ @@ -2352,192 +2408,124 @@ async def get( "resource_group_name", "organization_name", "project_name", - "branch_name", - "content_type", "accept", ] }, ) - async def _create_or_update_initial( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - resource: Union[_models.Branch, JSON, IO[bytes]], - **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 = kwargs.pop("params", {}) or {} + def list( + self, resource_group_name: str, organization_name: str, project_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Branch"]: + """List Branch resources by Project. - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Neon Organizations resource. Required. + :type organization_name: str + :param project_name: The name of the Project. Required. + :type project_name: str + :return: An iterator like instance of Branch + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.neonpostgres.models.Branch] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - content_type = content_type or "application/json" - _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource - else: - _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[List[_models.Branch]] = kwargs.pop("cls", None) - _request = build_branches_create_or_update_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - subscription_id=self._config.subscription_id, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + def prepare_request(next_link=None): + if not next_link: - response = pipeline_response.http_response + _request = build_branches_list_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - 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")) + return _request - deserialized = response.iter_bytes() + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Branch], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + async def get_next(next_link=None): + _request = prepare_request(next_link) - return deserialized # type: ignore + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - resource: _models.Branch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Branch]: - """Create a Branch. + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param resource: Resource create parameters. Required. - :type resource: ~azure.mgmt.neonpostgres.models.Branch - :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 Branch. The Branch is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Branch] - :raises ~azure.core.exceptions.HttpResponseError: - """ + return pipeline_response - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - resource: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Branch]: - """Create a Branch. + return AsyncItemPaged(get_next, extract_data) - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param resource: Resource create parameters. Required. - :type resource: JSON - :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 Branch. The Branch is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Branch] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Branch]: - """Create a Branch. +class ComputesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param resource: Resource create parameters. Required. - :type resource: 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 Branch. The Branch is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Branch] - :raises ~azure.core.exceptions.HttpResponseError: - """ + Instead, you should access the following operations through + :class:`~azure.mgmt.neonpostgres.aio.NeonPostgresMgmtClient`'s + :attr:`computes` attribute. + """ - @distributed_trace_async + 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: NeonPostgresMgmtClientConfiguration = 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 @api_version_validation( method_added_on="2025-03-01-preview", params_added_on={ @@ -2548,21 +2536,14 @@ async def begin_create_or_update( "organization_name", "project_name", "branch_name", - "content_type", "accept", ] }, ) - async def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - resource: Union[_models.Branch, JSON, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Branch]: - """Create a Branch. + def list( + self, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Compute"]: + """List Compute resources by Branch. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2573,92 +2554,15 @@ async def begin_create_or_update( :type project_name: str :param branch_name: The name of the Branch. Required. :type branch_name: str - :param resource: Resource create parameters. Is one of the following types: Branch, JSON, - IO[bytes] Required. - :type resource: ~azure.mgmt.neonpostgres.models.Branch or JSON or IO[bytes] - :return: An instance of AsyncLROPoller that returns Branch. The Branch is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Branch] + :return: An iterator like instance of Compute + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.neonpostgres.models.Compute] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Branch] = 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_or_update_initial( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - resource=resource, - 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): - response = pipeline_response.http_response - deserialized = _deserialize(_models.Branch, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Branch].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Branch]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + cls: ClsType[List[_models.Compute]] = kwargs.pop("cls", None) - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "content_type", - "accept", - ] - }, - ) - async def _update_initial( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - properties: Union[_models.Branch, JSON, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2667,77 +2571,110 @@ async def _update_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} + def prepare_request(next_link=None): + if not next_link: - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + _request = build_computes_list_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_name, + branch_name=branch_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - content_type = content_type or "application/json" - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _request = build_branches_update_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - subscription_id=self._config.subscription_id, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Compute], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - response = pipeline_response.http_response + async def get_next(next_link=None): + _request = prepare_request(next_link) - if response.status_code not in [200, 202]: - 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - 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")) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = response.iter_bytes() + return pipeline_response - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return AsyncItemPaged(get_next, extract_data) - return deserialized # type: ignore - @overload - async def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - properties: _models.Branch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Branch]: - """Update a Branch. +class NeonDatabasesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.neonpostgres.aio.NeonPostgresMgmtClient`'s + :attr:`neon_databases` attribute. + """ + + 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: NeonPostgresMgmtClientConfiguration = 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 + @api_version_validation( + method_added_on="2025-03-01-preview", + params_added_on={ + "2025-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + "branch_name", + "accept", + ] + }, + ) + def list( + self, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, **kwargs: Any + ) -> AsyncIterable["_models.NeonDatabase"]: + """List NeonDatabase resources by Branch. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -2748,3612 +2685,15 @@ async def begin_update( :type project_name: str :param branch_name: The name of the Branch. Required. :type branch_name: str - :param properties: The resource properties to be updated. Required. - :type properties: ~azure.mgmt.neonpostgres.models.Branch - :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 Branch. The Branch is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Branch] + :return: An iterator like instance of NeonDatabase + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.neonpostgres.models.NeonDatabase] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - @overload - async def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - properties: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Branch]: - """Update a Branch. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param properties: The resource properties to be updated. Required. - :type properties: JSON - :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 Branch. The Branch is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Branch] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Branch]: - """Update a Branch. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param properties: The resource properties to be updated. Required. - :type properties: 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 Branch. The Branch is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Branch] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "content_type", - "accept", - ] - }, - ) - async def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - properties: Union[_models.Branch, JSON, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Branch]: - """Update a Branch. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param properties: The resource properties to be updated. Is one of the following types: - Branch, JSON, IO[bytes] Required. - :type properties: ~azure.mgmt.neonpostgres.models.Branch or JSON or IO[bytes] - :return: An instance of AsyncLROPoller that returns Branch. The Branch is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Branch] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Branch] = 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._update_initial( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - properties=properties, - 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): - response = pipeline_response.http_response - deserialized = _deserialize(_models.Branch, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Branch].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Branch]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "accept", - ] - }, - ) - async def delete( - self, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, **kwargs: Any - ) -> None: - """Delete a Branch. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :return: None - :rtype: None - :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 = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_branches_delete_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "accept", - ] - }, - ) - def list( - self, resource_group_name: str, organization_name: str, project_name: str, **kwargs: Any - ) -> AsyncIterable["_models.Branch"]: - """List Branch resources by Project. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :return: An iterator like instance of Branch - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.neonpostgres.models.Branch] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.Branch]] = 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_branches_list_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - 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 - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Branch], deserialized.get("value", [])) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class ComputesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.neonpostgres.aio.NeonPostgresMgmtClient`'s - :attr:`computes` attribute. - """ - - 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: NeonPostgresMgmtClientConfiguration = 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 - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "compute_name", - "accept", - ] - }, - ) - async def get( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - compute_name: str, - **kwargs: Any - ) -> _models.Compute: - """Get a Compute. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param compute_name: The name of the Compute. Required. - :type compute_name: str - :return: Compute. The Compute is compatible with MutableMapping - :rtype: ~azure.mgmt.neonpostgres.models.Compute - :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 = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.Compute] = kwargs.pop("cls", None) - - _request = build_computes_get_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - compute_name=compute_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = kwargs.pop("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]: - if _stream: - 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.Compute, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "compute_name", - "content_type", - "accept", - ] - }, - ) - async def _create_or_update_initial( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - compute_name: str, - resource: Union[_models.Compute, JSON, IO[bytes]], - **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 = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource - else: - _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_computes_create_or_update_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - compute_name=compute_name, - subscription_id=self._config.subscription_id, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - 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.iter_bytes() - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - compute_name: str, - resource: _models.Compute, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Compute]: - """Create a Compute. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param compute_name: The name of the Compute. Required. - :type compute_name: str - :param resource: Resource create parameters. Required. - :type resource: ~azure.mgmt.neonpostgres.models.Compute - :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 Compute. The Compute is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Compute] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - compute_name: str, - resource: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Compute]: - """Create a Compute. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param compute_name: The name of the Compute. Required. - :type compute_name: str - :param resource: Resource create parameters. Required. - :type resource: JSON - :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 Compute. The Compute is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Compute] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - compute_name: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Compute]: - """Create a Compute. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param compute_name: The name of the Compute. Required. - :type compute_name: str - :param resource: Resource create parameters. Required. - :type resource: 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 Compute. The Compute is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Compute] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "compute_name", - "content_type", - "accept", - ] - }, - ) - async def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - compute_name: str, - resource: Union[_models.Compute, JSON, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Compute]: - """Create a Compute. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param compute_name: The name of the Compute. Required. - :type compute_name: str - :param resource: Resource create parameters. Is one of the following types: Compute, JSON, - IO[bytes] Required. - :type resource: ~azure.mgmt.neonpostgres.models.Compute or JSON or IO[bytes] - :return: An instance of AsyncLROPoller that returns Compute. The Compute is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Compute] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Compute] = 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_or_update_initial( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - compute_name=compute_name, - resource=resource, - 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): - response = pipeline_response.http_response - deserialized = _deserialize(_models.Compute, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Compute].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Compute]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "compute_name", - "content_type", - "accept", - ] - }, - ) - async def _update_initial( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - compute_name: str, - properties: Union[_models.Compute, JSON, IO[bytes]], - **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 = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_computes_update_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - compute_name=compute_name, - subscription_id=self._config.subscription_id, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _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, 202]: - 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - 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.iter_bytes() - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - compute_name: str, - properties: _models.Compute, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Compute]: - """Update a Compute. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param compute_name: The name of the Compute. Required. - :type compute_name: str - :param properties: The resource properties to be updated. Required. - :type properties: ~azure.mgmt.neonpostgres.models.Compute - :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 Compute. The Compute is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Compute] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - compute_name: str, - properties: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Compute]: - """Update a Compute. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param compute_name: The name of the Compute. Required. - :type compute_name: str - :param properties: The resource properties to be updated. Required. - :type properties: JSON - :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 Compute. The Compute is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Compute] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - compute_name: str, - properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Compute]: - """Update a Compute. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param compute_name: The name of the Compute. Required. - :type compute_name: str - :param properties: The resource properties to be updated. Required. - :type properties: 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 Compute. The Compute is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Compute] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "compute_name", - "content_type", - "accept", - ] - }, - ) - async def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - compute_name: str, - properties: Union[_models.Compute, JSON, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Compute]: - """Update a Compute. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param compute_name: The name of the Compute. Required. - :type compute_name: str - :param properties: The resource properties to be updated. Is one of the following types: - Compute, JSON, IO[bytes] Required. - :type properties: ~azure.mgmt.neonpostgres.models.Compute or JSON or IO[bytes] - :return: An instance of AsyncLROPoller that returns Compute. The Compute is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Compute] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Compute] = 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._update_initial( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - compute_name=compute_name, - properties=properties, - 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): - response = pipeline_response.http_response - deserialized = _deserialize(_models.Compute, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Compute].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Compute]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "compute_name", - "accept", - ] - }, - ) - async def delete( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - compute_name: str, - **kwargs: Any - ) -> None: - """Delete a Compute. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param compute_name: The name of the Compute. Required. - :type compute_name: str - :return: None - :rtype: None - :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 = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_computes_delete_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - compute_name=compute_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "accept", - ] - }, - ) - def list( - self, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, **kwargs: Any - ) -> AsyncIterable["_models.Compute"]: - """List Compute resources by Branch. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :return: An iterator like instance of Compute - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.neonpostgres.models.Compute] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.Compute]] = 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_computes_list_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - 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 - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Compute], deserialized.get("value", [])) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class NeonDatabasesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.neonpostgres.aio.NeonPostgresMgmtClient`'s - :attr:`neon_databases` attribute. - """ - - 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: NeonPostgresMgmtClientConfiguration = 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 - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "neon_database_name", - "accept", - ] - }, - ) - async def get( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_database_name: str, - **kwargs: Any - ) -> _models.NeonDatabase: - """Get a NeonDatabase. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_database_name: The name of the NeonDatabase. Required. - :type neon_database_name: str - :return: NeonDatabase. The NeonDatabase is compatible with MutableMapping - :rtype: ~azure.mgmt.neonpostgres.models.NeonDatabase - :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 = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.NeonDatabase] = kwargs.pop("cls", None) - - _request = build_neon_databases_get_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - neon_database_name=neon_database_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = kwargs.pop("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]: - if _stream: - 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.NeonDatabase, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "neon_database_name", - "content_type", - "accept", - ] - }, - ) - async def _create_or_update_initial( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_database_name: str, - resource: Union[_models.NeonDatabase, JSON, IO[bytes]], - **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 = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource - else: - _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_neon_databases_create_or_update_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - neon_database_name=neon_database_name, - subscription_id=self._config.subscription_id, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - 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.iter_bytes() - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_database_name: str, - resource: _models.NeonDatabase, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.NeonDatabase]: - """Create a NeonDatabase. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_database_name: The name of the NeonDatabase. Required. - :type neon_database_name: str - :param resource: Resource create parameters. Required. - :type resource: ~azure.mgmt.neonpostgres.models.NeonDatabase - :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 NeonDatabase. The NeonDatabase is - compatible with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.NeonDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_database_name: str, - resource: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.NeonDatabase]: - """Create a NeonDatabase. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_database_name: The name of the NeonDatabase. Required. - :type neon_database_name: str - :param resource: Resource create parameters. Required. - :type resource: JSON - :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 NeonDatabase. The NeonDatabase is - compatible with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.NeonDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_database_name: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.NeonDatabase]: - """Create a NeonDatabase. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_database_name: The name of the NeonDatabase. Required. - :type neon_database_name: str - :param resource: Resource create parameters. Required. - :type resource: 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 NeonDatabase. The NeonDatabase is - compatible with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.NeonDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "neon_database_name", - "content_type", - "accept", - ] - }, - ) - async def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_database_name: str, - resource: Union[_models.NeonDatabase, JSON, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.NeonDatabase]: - """Create a NeonDatabase. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_database_name: The name of the NeonDatabase. Required. - :type neon_database_name: str - :param resource: Resource create parameters. Is one of the following types: NeonDatabase, JSON, - IO[bytes] Required. - :type resource: ~azure.mgmt.neonpostgres.models.NeonDatabase or JSON or IO[bytes] - :return: An instance of AsyncLROPoller that returns NeonDatabase. The NeonDatabase is - compatible with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.NeonDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.NeonDatabase] = 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_or_update_initial( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - neon_database_name=neon_database_name, - resource=resource, - 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): - response = pipeline_response.http_response - deserialized = _deserialize(_models.NeonDatabase, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.NeonDatabase].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.NeonDatabase]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "neon_database_name", - "content_type", - "accept", - ] - }, - ) - async def _update_initial( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_database_name: str, - properties: Union[_models.NeonDatabase, JSON, IO[bytes]], - **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 = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_neon_databases_update_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - neon_database_name=neon_database_name, - subscription_id=self._config.subscription_id, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _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, 202]: - 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - 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.iter_bytes() - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_database_name: str, - properties: _models.NeonDatabase, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.NeonDatabase]: - """Update a NeonDatabase. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_database_name: The name of the NeonDatabase. Required. - :type neon_database_name: str - :param properties: The resource properties to be updated. Required. - :type properties: ~azure.mgmt.neonpostgres.models.NeonDatabase - :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 NeonDatabase. The NeonDatabase is - compatible with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.NeonDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_database_name: str, - properties: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.NeonDatabase]: - """Update a NeonDatabase. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_database_name: The name of the NeonDatabase. Required. - :type neon_database_name: str - :param properties: The resource properties to be updated. Required. - :type properties: JSON - :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 NeonDatabase. The NeonDatabase is - compatible with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.NeonDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_database_name: str, - properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.NeonDatabase]: - """Update a NeonDatabase. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_database_name: The name of the NeonDatabase. Required. - :type neon_database_name: str - :param properties: The resource properties to be updated. Required. - :type properties: 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 NeonDatabase. The NeonDatabase is - compatible with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.NeonDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "neon_database_name", - "content_type", - "accept", - ] - }, - ) - async def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_database_name: str, - properties: Union[_models.NeonDatabase, JSON, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.NeonDatabase]: - """Update a NeonDatabase. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_database_name: The name of the NeonDatabase. Required. - :type neon_database_name: str - :param properties: The resource properties to be updated. Is one of the following types: - NeonDatabase, JSON, IO[bytes] Required. - :type properties: ~azure.mgmt.neonpostgres.models.NeonDatabase or JSON or IO[bytes] - :return: An instance of AsyncLROPoller that returns NeonDatabase. The NeonDatabase is - compatible with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.NeonDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.NeonDatabase] = 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._update_initial( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - neon_database_name=neon_database_name, - properties=properties, - 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): - response = pipeline_response.http_response - deserialized = _deserialize(_models.NeonDatabase, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.NeonDatabase].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.NeonDatabase]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "neon_database_name", - "accept", - ] - }, - ) - async def delete( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_database_name: str, - **kwargs: Any - ) -> None: - """Delete a NeonDatabase. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_database_name: The name of the NeonDatabase. Required. - :type neon_database_name: str - :return: None - :rtype: None - :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 = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_neon_databases_delete_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - neon_database_name=neon_database_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "accept", - ] - }, - ) - def list( - self, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, **kwargs: Any - ) -> AsyncIterable["_models.NeonDatabase"]: - """List NeonDatabase resources by Branch. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :return: An iterator like instance of NeonDatabase - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.neonpostgres.models.NeonDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.NeonDatabase]] = 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_neon_databases_list_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - 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 - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.NeonDatabase], deserialized.get("value", [])) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class NeonRolesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.neonpostgres.aio.NeonPostgresMgmtClient`'s - :attr:`neon_roles` attribute. - """ - - 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: NeonPostgresMgmtClientConfiguration = 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 - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "neon_role_name", - "accept", - ] - }, - ) - async def get( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_role_name: str, - **kwargs: Any - ) -> _models.NeonRole: - """Get a NeonRole. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_role_name: The name of the NeonRole. Required. - :type neon_role_name: str - :return: NeonRole. The NeonRole is compatible with MutableMapping - :rtype: ~azure.mgmt.neonpostgres.models.NeonRole - :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 = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.NeonRole] = kwargs.pop("cls", None) - - _request = build_neon_roles_get_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - neon_role_name=neon_role_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = kwargs.pop("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]: - if _stream: - 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.NeonRole, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "neon_role_name", - "content_type", - "accept", - ] - }, - ) - async def _create_or_update_initial( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_role_name: str, - resource: Union[_models.NeonRole, JSON, IO[bytes]], - **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 = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource - else: - _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_neon_roles_create_or_update_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - neon_role_name=neon_role_name, - subscription_id=self._config.subscription_id, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - 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.iter_bytes() - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_role_name: str, - resource: _models.NeonRole, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.NeonRole]: - """Create a NeonRole. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_role_name: The name of the NeonRole. Required. - :type neon_role_name: str - :param resource: Resource create parameters. Required. - :type resource: ~azure.mgmt.neonpostgres.models.NeonRole - :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 NeonRole. The NeonRole is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.NeonRole] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_role_name: str, - resource: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.NeonRole]: - """Create a NeonRole. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_role_name: The name of the NeonRole. Required. - :type neon_role_name: str - :param resource: Resource create parameters. Required. - :type resource: JSON - :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 NeonRole. The NeonRole is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.NeonRole] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_role_name: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.NeonRole]: - """Create a NeonRole. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_role_name: The name of the NeonRole. Required. - :type neon_role_name: str - :param resource: Resource create parameters. Required. - :type resource: 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 NeonRole. The NeonRole is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.NeonRole] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "neon_role_name", - "content_type", - "accept", - ] - }, - ) - async def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_role_name: str, - resource: Union[_models.NeonRole, JSON, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.NeonRole]: - """Create a NeonRole. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_role_name: The name of the NeonRole. Required. - :type neon_role_name: str - :param resource: Resource create parameters. Is one of the following types: NeonRole, JSON, - IO[bytes] Required. - :type resource: ~azure.mgmt.neonpostgres.models.NeonRole or JSON or IO[bytes] - :return: An instance of AsyncLROPoller that returns NeonRole. The NeonRole is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.NeonRole] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.NeonRole] = 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_or_update_initial( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - neon_role_name=neon_role_name, - resource=resource, - 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): - response = pipeline_response.http_response - deserialized = _deserialize(_models.NeonRole, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.NeonRole].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.NeonRole]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "neon_role_name", - "content_type", - "accept", - ] - }, - ) - async def _update_initial( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_role_name: str, - properties: Union[_models.NeonRole, JSON, IO[bytes]], - **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 = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_neon_roles_update_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - neon_role_name=neon_role_name, - subscription_id=self._config.subscription_id, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _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, 202]: - 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - 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.iter_bytes() - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_role_name: str, - properties: _models.NeonRole, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.NeonRole]: - """Update a NeonRole. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_role_name: The name of the NeonRole. Required. - :type neon_role_name: str - :param properties: The resource properties to be updated. Required. - :type properties: ~azure.mgmt.neonpostgres.models.NeonRole - :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 NeonRole. The NeonRole is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.NeonRole] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_role_name: str, - properties: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.NeonRole]: - """Update a NeonRole. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_role_name: The name of the NeonRole. Required. - :type neon_role_name: str - :param properties: The resource properties to be updated. Required. - :type properties: JSON - :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 NeonRole. The NeonRole is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.NeonRole] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_role_name: str, - properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.NeonRole]: - """Update a NeonRole. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_role_name: The name of the NeonRole. Required. - :type neon_role_name: str - :param properties: The resource properties to be updated. Required. - :type properties: 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 NeonRole. The NeonRole is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.NeonRole] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "neon_role_name", - "content_type", - "accept", - ] - }, - ) - async def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_role_name: str, - properties: Union[_models.NeonRole, JSON, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.NeonRole]: - """Update a NeonRole. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_role_name: The name of the NeonRole. Required. - :type neon_role_name: str - :param properties: The resource properties to be updated. Is one of the following types: - NeonRole, JSON, IO[bytes] Required. - :type properties: ~azure.mgmt.neonpostgres.models.NeonRole or JSON or IO[bytes] - :return: An instance of AsyncLROPoller that returns NeonRole. The NeonRole is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.NeonRole] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.NeonRole] = 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._update_initial( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - neon_role_name=neon_role_name, - properties=properties, - 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): - response = pipeline_response.http_response - deserialized = _deserialize(_models.NeonRole, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.NeonRole].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.NeonRole]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "neon_role_name", - "accept", - ] - }, - ) - async def delete( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_role_name: str, - **kwargs: Any - ) -> None: - """Delete a NeonRole. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_role_name: The name of the NeonRole. Required. - :type neon_role_name: str - :return: None - :rtype: None - :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 = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_neon_roles_delete_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - neon_role_name=neon_role_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "accept", - ] - }, - ) - def list( - self, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, **kwargs: Any - ) -> AsyncIterable["_models.NeonRole"]: - """List NeonRole resources by Branch. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :return: An iterator like instance of NeonRole - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.neonpostgres.models.NeonRole] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.NeonRole]] = 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_neon_roles_list_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - 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 - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.NeonRole], deserialized.get("value", [])) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class EndpointsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.neonpostgres.aio.NeonPostgresMgmtClient`'s - :attr:`endpoints` attribute. - """ - - 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: NeonPostgresMgmtClientConfiguration = 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 - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "endpoint_name", - "accept", - ] - }, - ) - async def get( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - endpoint_name: str, - **kwargs: Any - ) -> _models.Endpoint: - """Get a Endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param endpoint_name: The name of the Endpoint. Required. - :type endpoint_name: str - :return: Endpoint. The Endpoint is compatible with MutableMapping - :rtype: ~azure.mgmt.neonpostgres.models.Endpoint - :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 = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) - - _request = build_endpoints_get_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = kwargs.pop("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]: - if _stream: - 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.Endpoint, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "endpoint_name", - "content_type", - "accept", - ] - }, - ) - async def _create_or_update_initial( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - endpoint_name: str, - resource: Union[_models.Endpoint, JSON, IO[bytes]], - **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 = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource - else: - _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_endpoints_create_or_update_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - 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.iter_bytes() - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - endpoint_name: str, - resource: _models.Endpoint, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Endpoint]: - """Create a Endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param endpoint_name: The name of the Endpoint. Required. - :type endpoint_name: str - :param resource: Resource create parameters. Required. - :type resource: ~azure.mgmt.neonpostgres.models.Endpoint - :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 Endpoint. The Endpoint is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Endpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - endpoint_name: str, - resource: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Endpoint]: - """Create a Endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param endpoint_name: The name of the Endpoint. Required. - :type endpoint_name: str - :param resource: Resource create parameters. Required. - :type resource: JSON - :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 Endpoint. The Endpoint is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Endpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - endpoint_name: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Endpoint]: - """Create a Endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param endpoint_name: The name of the Endpoint. Required. - :type endpoint_name: str - :param resource: Resource create parameters. Required. - :type resource: 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 Endpoint. The Endpoint is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Endpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "endpoint_name", - "content_type", - "accept", - ] - }, - ) - async def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - endpoint_name: str, - resource: Union[_models.Endpoint, JSON, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Endpoint]: - """Create a Endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param endpoint_name: The name of the Endpoint. Required. - :type endpoint_name: str - :param resource: Resource create parameters. Is one of the following types: Endpoint, JSON, - IO[bytes] Required. - :type resource: ~azure.mgmt.neonpostgres.models.Endpoint or JSON or IO[bytes] - :return: An instance of AsyncLROPoller that returns Endpoint. The Endpoint is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Endpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Endpoint] = 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_or_update_initial( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - endpoint_name=endpoint_name, - resource=resource, - 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): - response = pipeline_response.http_response - deserialized = _deserialize(_models.Endpoint, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Endpoint].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Endpoint]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + cls: ClsType[List[_models.NeonDatabase]] = kwargs.pop("cls", None) - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "endpoint_name", - "content_type", - "accept", - ] - }, - ) - async def _update_initial( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - endpoint_name: str, - properties: Union[_models.Endpoint, JSON, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6362,280 +2702,92 @@ async def _update_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_endpoints_update_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _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, 202]: - 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - 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.iter_bytes() - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - endpoint_name: str, - properties: _models.Endpoint, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Endpoint]: - """Update a Endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param endpoint_name: The name of the Endpoint. Required. - :type endpoint_name: str - :param properties: The resource properties to be updated. Required. - :type properties: ~azure.mgmt.neonpostgres.models.Endpoint - :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 Endpoint. The Endpoint is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Endpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - endpoint_name: str, - properties: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Endpoint]: - """Update a Endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param endpoint_name: The name of the Endpoint. Required. - :type endpoint_name: str - :param properties: The resource properties to be updated. Required. - :type properties: JSON - :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 Endpoint. The Endpoint is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Endpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - endpoint_name: str, - properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Endpoint]: - """Update a Endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param endpoint_name: The name of the Endpoint. Required. - :type endpoint_name: str - :param properties: The resource properties to be updated. Required. - :type properties: 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 Endpoint. The Endpoint is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Endpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ + def prepare_request(next_link=None): + if not next_link: - @distributed_trace_async - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "endpoint_name", - "content_type", - "accept", - ] - }, - ) - async def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - endpoint_name: str, - properties: Union[_models.Endpoint, JSON, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Endpoint]: - """Update a Endpoint. + _request = build_neon_databases_list_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_name, + branch_name=branch_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param endpoint_name: The name of the Endpoint. Required. - :type endpoint_name: str - :param properties: The resource properties to be updated. Is one of the following types: - Endpoint, JSON, IO[bytes] Required. - :type properties: ~azure.mgmt.neonpostgres.models.Endpoint or JSON or IO[bytes] - :return: An instance of AsyncLROPoller that returns Endpoint. The Endpoint is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Endpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Endpoint] = 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._update_initial( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - endpoint_name=endpoint_name, - properties=properties, - 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) + return _request - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = _deserialize(_models.Endpoint, response.json()) + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.NeonDatabase], deserialized.get("value", [])) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } + async def get_next(next_link=None): + _request = prepare_request(next_link) - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Endpoint].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - return AsyncLROPoller[_models.Endpoint]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + response = pipeline_response.http_response - @distributed_trace_async + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class NeonRolesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.neonpostgres.aio.NeonPostgresMgmtClient`'s + :attr:`neon_roles` attribute. + """ + + 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: NeonPostgresMgmtClientConfiguration = 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 @api_version_validation( method_added_on="2025-03-01-preview", params_added_on={ @@ -6646,21 +2798,14 @@ def get_long_running_output(pipeline_response): "organization_name", "project_name", "branch_name", - "endpoint_name", "accept", ] }, ) - async def delete( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - endpoint_name: str, - **kwargs: Any - ) -> None: - """Delete a Endpoint. + def list( + self, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, **kwargs: Any + ) -> AsyncIterable["_models.NeonRole"]: + """List NeonRole resources by Branch. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -6671,12 +2816,15 @@ async def delete( :type project_name: str :param branch_name: The name of the Branch. Required. :type branch_name: str - :param endpoint_name: The name of the Endpoint. Required. - :type endpoint_name: str - :return: None - :rtype: None + :return: An iterator like instance of NeonRole + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.neonpostgres.models.NeonRole] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.NeonRole]] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6685,41 +2833,90 @@ async def delete( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} + def prepare_request(next_link=None): + if not next_link: - cls: ClsType[None] = kwargs.pop("cls", None) + _request = build_neon_roles_list_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_name, + branch_name=branch_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _request = build_endpoints_delete_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + return _request - response = pipeline_response.http_response + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.NeonRole], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + async def get_next(next_link=None): + _request = prepare_request(next_link) - if cls: - return cls(pipeline_response, None, {}) # type: ignore + _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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class EndpointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.neonpostgres.aio.NeonPostgresMgmtClient`'s + :attr:`endpoints` attribute. + """ + + 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: NeonPostgresMgmtClientConfiguration = 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 @api_version_validation( diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/models/_models.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/models/_models.py index bde11f26369a..996ce08e092d 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/models/_models.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/models/_models.py @@ -11,14 +11,13 @@ import datetime from typing import Any, Dict, List, Mapping, Optional, TYPE_CHECKING, Union, overload -from .. import _model_base -from .._model_base import rest_field +from .._utils.model_base import Model as _Model, rest_field if TYPE_CHECKING: from .. import models as _models -class Attributes(_model_base.Model): +class Attributes(_Model): """Additional attributes specific to Neon Resources. :ivar name: Name of the attribute. Required. @@ -51,7 +50,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class Resource(_model_base.Model): +class Resource(_Model): """Common fields that are returned in the response for all Azure Resource Manager resources. :ivar id: Fully qualified resource ID for the resource. Ex - @@ -138,7 +137,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class BranchProperties(_model_base.Model): +class BranchProperties(_Model): """Properties specific to Branch. :ivar entity_id: Unique identifier for the entity. @@ -234,7 +233,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class CompanyDetails(_model_base.Model): +class CompanyDetails(_Model): """Company details for an organization. :ivar company_name: Company name. @@ -336,7 +335,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class ComputeProperties(_model_base.Model): +class ComputeProperties(_Model): """Properties specific to Compute. :ivar entity_id: Unique identifier for the entity. @@ -409,7 +408,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class ConnectionUriProperties(_model_base.Model): +class ConnectionUriProperties(_Model): """Connection uri parameters for the associated database. :ivar project_id: Project Id associated with this connection. @@ -470,7 +469,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class DefaultEndpointSettings(_model_base.Model): +class DefaultEndpointSettings(_Model): """Default Endpoint Settings for the project. :ivar autoscaling_limit_min_cu: Minimum compute units for autoscaling. Required. @@ -548,7 +547,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class EndpointProperties(_model_base.Model): +class EndpointProperties(_Model): """Properties specific to Endpoints. :ivar entity_id: Unique identifier for the entity. @@ -618,7 +617,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class ErrorAdditionalInfo(_model_base.Model): +class ErrorAdditionalInfo(_Model): """The resource management error additional info. :ivar type: The additional info type. @@ -633,7 +632,7 @@ class ErrorAdditionalInfo(_model_base.Model): """The additional info.""" -class ErrorDetail(_model_base.Model): +class ErrorDetail(_Model): """The error detail. :ivar code: The error code. @@ -662,7 +661,7 @@ class ErrorDetail(_model_base.Model): """The error additional info.""" -class ErrorResponse(_model_base.Model): +class ErrorResponse(_Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. @@ -691,7 +690,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class MarketplaceDetails(_model_base.Model): +class MarketplaceDetails(_Model): """Marketplace details for an organization. :ivar subscription_id: SaaS subscription id for the the marketplace offer. @@ -779,7 +778,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class NeonDatabaseProperties(_model_base.Model): +class NeonDatabaseProperties(_Model): """Properties specific to Databases. :ivar entity_id: Unique identifier for the entity. @@ -883,7 +882,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class NeonRoleProperties(_model_base.Model): +class NeonRoleProperties(_Model): """Properties specific to Roles. :ivar entity_id: Unique identifier for the entity. @@ -953,7 +952,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class OfferDetails(_model_base.Model): +class OfferDetails(_Model): """Offer details for the marketplace that is selected by the user. :ivar publisher_id: Publisher Id for the marketplace offer. Required. @@ -1006,7 +1005,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class Operation(_model_base.Model): +class Operation(_Model): """Details of a REST API operation, returned from the Resource Provider Operations API. :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: @@ -1063,7 +1062,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class OperationDisplay(_model_base.Model): +class OperationDisplay(_Model): """Localized display information for and operation. :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft @@ -1094,7 +1093,7 @@ class OperationDisplay(_model_base.Model): views.""" -class OrganizationProperties(_model_base.Model): +class OrganizationProperties(_Model): """Properties specific to Neon Organization resource. :ivar marketplace_details: Marketplace details of the resource. Required. @@ -1114,7 +1113,7 @@ class OrganizationProperties(_model_base.Model): """ marketplace_details: "_models.MarketplaceDetails" = rest_field( - name="marketplaceDetails", visibility=["read", "create"] + name="marketplaceDetails", visibility=["read", "create", "update"] ) """Marketplace details of the resource. Required.""" user_details: "_models.UserDetails" = rest_field( @@ -1253,7 +1252,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class PartnerOrganizationProperties(_model_base.Model): +class PartnerOrganizationProperties(_Model): """Properties specific to Partner's organization. :ivar organization_id: Organization Id in partner's system. @@ -1297,7 +1296,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class PgVersion(_model_base.Model): +class PgVersion(_Model): """PostgreSQL Version model. :ivar version: The major PostgreSQL version number. @@ -1325,7 +1324,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class PgVersionsResult(_model_base.Model): +class PgVersionsResult(_Model): """Response model for PostgreSQL versions. :ivar versions: List of PostgreSQL versions. Required. @@ -1394,7 +1393,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class ProjectProperties(_model_base.Model): +class ProjectProperties(_Model): """Properties specific to Project. :ivar entity_id: Unique identifier for the entity. @@ -1504,7 +1503,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class SingleSignOnProperties(_model_base.Model): +class SingleSignOnProperties(_Model): """Properties specific to Single Sign On Resource. :ivar single_sign_on_state: State of the Single Sign On for the organization. Known values are: @@ -1558,7 +1557,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class SystemData(_model_base.Model): +class SystemData(_Model): """Metadata pertaining to creation and last modification of the resource. :ivar created_by: The identity that created the resource. @@ -1625,7 +1624,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class UserDetails(_model_base.Model): +class UserDetails(_Model): """User details for an organization. :ivar first_name: First name of the user. diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/operations/__init__.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/operations/__init__.py index 2828a5d7896d..6e7dd0fed8a3 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/operations/__init__.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/operations/__init__.py @@ -12,7 +12,6 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._operations import ModelsOperations # type: ignore from ._operations import Operations # type: ignore from ._operations import OrganizationsOperations # type: ignore from ._operations import ProjectsOperations # type: ignore @@ -27,7 +26,6 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ - "ModelsOperations", "Operations", "OrganizationsOperations", "ProjectsOperations", diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/operations/_operations.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/operations/_operations.py index f0b305ce4e54..93d2099454eb 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/operations/_operations.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/operations/_operations.py @@ -6,9 +6,9 @@ # Code generated by Microsoft (R) Python 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 json -import sys from typing import Any, Callable, Dict, IO, Iterable, Iterator, List, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -34,17 +34,13 @@ from .. import models as _models from .._configuration import NeonPostgresMgmtClientConfiguration -from .._model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize -from .._serialization import Deserializer, Serializer +from .._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize +from .._utils.serialization import Deserializer, Serializer from .._validation import api_version_validation -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]] -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +JSON = MutableMapping[str, Any] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False @@ -333,38 +329,6 @@ def build_projects_create_or_update_request( return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_projects_update_request( - resource_group_name: str, organization_name: str, project_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}/projects/{projectName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_name, "str"), - } - - _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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - def build_projects_delete_request( resource_group_name: str, organization_name: str, project_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: @@ -527,44 +491,6 @@ def build_branches_create_or_update_request( return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_branches_update_request( - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}/projects/{projectName}/branches/{branchName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_name, "str"), - "branchName": _SERIALIZER.url("branch_name", branch_name, "str"), - } - - _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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - def build_branches_delete_request( resource_group_name: str, organization_name: str, @@ -629,12 +555,11 @@ def build_branches_list_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_computes_get_request( +def build_computes_list_request( resource_group_name: str, organization_name: str, project_name: str, branch_name: str, - compute_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: @@ -645,14 +570,13 @@ def build_computes_get_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}/projects/{projectName}/branches/{branchName}/computes/{computeName}" + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}/projects/{projectName}/branches/{branchName}/computes" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), "projectName": _SERIALIZER.url("project_name", project_name, "str"), "branchName": _SERIALIZER.url("branch_name", branch_name, "str"), - "computeName": _SERIALIZER.url("compute_name", compute_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -666,31 +590,28 @@ def build_computes_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_computes_create_or_update_request( +def build_neon_databases_list_request( resource_group_name: str, organization_name: str, project_name: str, branch_name: str, - compute_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - 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")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}/projects/{projectName}/branches/{branchName}/computes/{computeName}" + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}/projects/{projectName}/branches/{branchName}/neonDatabases" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), "projectName": _SERIALIZER.url("project_name", project_name, "str"), "branchName": _SERIALIZER.url("branch_name", branch_name, "str"), - "computeName": _SERIALIZER.url("compute_name", compute_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -699,38 +620,33 @@ def build_computes_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_computes_update_request( +def build_neon_roles_list_request( resource_group_name: str, organization_name: str, project_name: str, branch_name: str, - compute_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - 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")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}/projects/{projectName}/branches/{branchName}/computes/{computeName}" + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}/projects/{projectName}/branches/{branchName}/neonRoles" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), "projectName": _SERIALIZER.url("project_name", project_name, "str"), "branchName": _SERIALIZER.url("branch_name", branch_name, "str"), - "computeName": _SERIALIZER.url("compute_name", compute_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -739,19 +655,16 @@ def build_computes_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_computes_delete_request( +def build_endpoints_list_request( resource_group_name: str, organization_name: str, project_name: str, branch_name: str, - compute_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: @@ -762,14 +675,13 @@ def build_computes_delete_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}/projects/{projectName}/branches/{branchName}/computes/{computeName}" + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}/projects/{projectName}/branches/{branchName}/endpoints" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), "projectName": _SERIALIZER.url("project_name", project_name, "str"), "branchName": _SERIALIZER.url("branch_name", branch_name, "str"), - "computeName": _SERIALIZER.url("compute_name", compute_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -780,4559 +692,119 @@ def build_computes_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_computes_list_request( - resource_group_name: str, - organization_name: str, - project_name: str, - branch_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")) - accept = _headers.pop("Accept", "application/json") +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}/projects/{projectName}/branches/{branchName}/computes" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_name, "str"), - "branchName": _SERIALIZER.url("branch_name", branch_name, "str"), - } + Instead, you should access the following operations through + :class:`~azure.mgmt.neonpostgres.NeonPostgresMgmtClient`'s + :attr:`operations` attribute. + """ - _url: str = _url.format(**path_format_arguments) # type: ignore + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: NeonPostgresMgmtClientConfiguration = 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") - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: + """List the operations for the provider. - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + :return: An iterator like instance of Operation + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.neonpostgres.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + cls: ClsType[List[_models.Operation]] = kwargs.pop("cls", None) + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) -def build_neon_databases_get_request( - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_database_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) - accept = _headers.pop("Accept", "application/json") + _request = build_operations_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}/projects/{projectName}/branches/{branchName}/neonDatabases/{neonDatabaseName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_name, "str"), - "branchName": _SERIALIZER.url("branch_name", branch_name, "str"), - "neonDatabaseName": _SERIALIZER.url("neon_database_name", neon_database_name, "str"), - } + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _url: str = _url.format(**path_format_arguments) # type: ignore + return _request - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Operation], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + def get_next(next_link=None): + _request = prepare_request(next_link) - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + _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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) -def build_neon_databases_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_database_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + return pipeline_response - 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")) - accept = _headers.pop("Accept", "application/json") + return ItemPaged(get_next, extract_data) - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}/projects/{projectName}/branches/{branchName}/neonDatabases/{neonDatabaseName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_name, "str"), - "branchName": _SERIALIZER.url("branch_name", branch_name, "str"), - "neonDatabaseName": _SERIALIZER.url("neon_database_name", neon_database_name, "str"), - } - _url: str = _url.format(**path_format_arguments) # type: ignore +class OrganizationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - # 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_neon_databases_update_request( - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_database_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}/projects/{projectName}/branches/{branchName}/neonDatabases/{neonDatabaseName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_name, "str"), - "branchName": _SERIALIZER.url("branch_name", branch_name, "str"), - "neonDatabaseName": _SERIALIZER.url("neon_database_name", neon_database_name, "str"), - } - - _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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_neon_databases_delete_request( - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_database_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")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}/projects/{projectName}/branches/{branchName}/neonDatabases/{neonDatabaseName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_name, "str"), - "branchName": _SERIALIZER.url("branch_name", branch_name, "str"), - "neonDatabaseName": _SERIALIZER.url("neon_database_name", neon_database_name, "str"), - } - - _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) - - -def build_neon_databases_list_request( - resource_group_name: str, - organization_name: str, - project_name: str, - branch_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")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}/projects/{projectName}/branches/{branchName}/neonDatabases" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_name, "str"), - "branchName": _SERIALIZER.url("branch_name", branch_name, "str"), - } - - _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_neon_roles_get_request( - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_role_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")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}/projects/{projectName}/branches/{branchName}/neonRoles/{neonRoleName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_name, "str"), - "branchName": _SERIALIZER.url("branch_name", branch_name, "str"), - "neonRoleName": _SERIALIZER.url("neon_role_name", neon_role_name, "str"), - } - - _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_neon_roles_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_role_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}/projects/{projectName}/branches/{branchName}/neonRoles/{neonRoleName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_name, "str"), - "branchName": _SERIALIZER.url("branch_name", branch_name, "str"), - "neonRoleName": _SERIALIZER.url("neon_role_name", neon_role_name, "str"), - } - - _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_neon_roles_update_request( - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_role_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}/projects/{projectName}/branches/{branchName}/neonRoles/{neonRoleName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_name, "str"), - "branchName": _SERIALIZER.url("branch_name", branch_name, "str"), - "neonRoleName": _SERIALIZER.url("neon_role_name", neon_role_name, "str"), - } - - _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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_neon_roles_delete_request( - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_role_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")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}/projects/{projectName}/branches/{branchName}/neonRoles/{neonRoleName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_name, "str"), - "branchName": _SERIALIZER.url("branch_name", branch_name, "str"), - "neonRoleName": _SERIALIZER.url("neon_role_name", neon_role_name, "str"), - } - - _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) - - -def build_neon_roles_list_request( - resource_group_name: str, - organization_name: str, - project_name: str, - branch_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")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}/projects/{projectName}/branches/{branchName}/neonRoles" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_name, "str"), - "branchName": _SERIALIZER.url("branch_name", branch_name, "str"), - } - - _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_endpoints_get_request( - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - endpoint_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")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}/projects/{projectName}/branches/{branchName}/endpoints/{endpointName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_name, "str"), - "branchName": _SERIALIZER.url("branch_name", branch_name, "str"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - } - - _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_endpoints_create_or_update_request( - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - endpoint_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}/projects/{projectName}/branches/{branchName}/endpoints/{endpointName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_name, "str"), - "branchName": _SERIALIZER.url("branch_name", branch_name, "str"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - } - - _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_endpoints_update_request( - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - endpoint_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}/projects/{projectName}/branches/{branchName}/endpoints/{endpointName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_name, "str"), - "branchName": _SERIALIZER.url("branch_name", branch_name, "str"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - } - - _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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_endpoints_delete_request( - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - endpoint_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")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}/projects/{projectName}/branches/{branchName}/endpoints/{endpointName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_name, "str"), - "branchName": _SERIALIZER.url("branch_name", branch_name, "str"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - } - - _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) - - -def build_endpoints_list_request( - resource_group_name: str, - organization_name: str, - project_name: str, - branch_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")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}/projects/{projectName}/branches/{branchName}/endpoints" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), - "projectName": _SERIALIZER.url("project_name", project_name, "str"), - "branchName": _SERIALIZER.url("branch_name", branch_name, "str"), - } - - _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) - - -class ModelsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.neonpostgres.NeonPostgresMgmtClient`'s - :attr:`models` attribute. - """ - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: NeonPostgresMgmtClientConfiguration = 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") - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.neonpostgres.NeonPostgresMgmtClient`'s - :attr:`operations` attribute. - """ - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: NeonPostgresMgmtClientConfiguration = 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.Operation"]: - """List the operations for the provider. - - :return: An iterator like instance of Operation - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.neonpostgres.models.Operation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.Operation]] = 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_operations_list_request( - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - 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 - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Operation], deserialized.get("value", [])) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class OrganizationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.neonpostgres.NeonPostgresMgmtClient`'s - :attr:`organizations` attribute. - """ - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: NeonPostgresMgmtClientConfiguration = 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 get(self, resource_group_name: str, organization_name: str, **kwargs: Any) -> _models.OrganizationResource: - """Get a OrganizationResource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :return: OrganizationResource. The OrganizationResource is compatible with MutableMapping - :rtype: ~azure.mgmt.neonpostgres.models.OrganizationResource - :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 = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.OrganizationResource] = kwargs.pop("cls", None) - - _request = build_organizations_get_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = kwargs.pop("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]: - if _stream: - 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.OrganizationResource, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - organization_name: str, - resource: Union[_models.OrganizationResource, JSON, IO[bytes]], - **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 = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource - else: - _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_organizations_create_or_update_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - subscription_id=self._config.subscription_id, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - 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.iter_bytes() - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - resource: _models.OrganizationResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OrganizationResource]: - """Create a OrganizationResource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param resource: Resource create parameters. Required. - :type resource: ~azure.mgmt.neonpostgres.models.OrganizationResource - :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 OrganizationResource. The OrganizationResource - is compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.OrganizationResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - resource: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OrganizationResource]: - """Create a OrganizationResource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param resource: Resource create parameters. Required. - :type resource: JSON - :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 OrganizationResource. The OrganizationResource - is compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.OrganizationResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OrganizationResource]: - """Create a OrganizationResource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param resource: Resource create parameters. Required. - :type resource: 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 OrganizationResource. The OrganizationResource - is compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.OrganizationResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - resource: Union[_models.OrganizationResource, JSON, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.OrganizationResource]: - """Create a OrganizationResource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param resource: Resource create parameters. Is one of the following types: - OrganizationResource, JSON, IO[bytes] Required. - :type resource: ~azure.mgmt.neonpostgres.models.OrganizationResource or JSON or IO[bytes] - :return: An instance of LROPoller that returns OrganizationResource. The OrganizationResource - is compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.OrganizationResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OrganizationResource] = 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_or_update_initial( - resource_group_name=resource_group_name, - organization_name=organization_name, - resource=resource, - 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): - response = pipeline_response.http_response - deserialized = _deserialize(_models.OrganizationResource, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OrganizationResource].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OrganizationResource]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - organization_name: str, - properties: Union[_models.OrganizationResource, JSON, IO[bytes]], - **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 = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_organizations_update_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - subscription_id=self._config.subscription_id, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _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, 202]: - 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - 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.iter_bytes() - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - organization_name: str, - properties: _models.OrganizationResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OrganizationResource]: - """Update a OrganizationResource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param properties: The resource properties to be updated. Required. - :type properties: ~azure.mgmt.neonpostgres.models.OrganizationResource - :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 OrganizationResource. The OrganizationResource - is compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.OrganizationResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - organization_name: str, - properties: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OrganizationResource]: - """Update a OrganizationResource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param properties: The resource properties to be updated. Required. - :type properties: JSON - :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 OrganizationResource. The OrganizationResource - is compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.OrganizationResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - organization_name: str, - properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OrganizationResource]: - """Update a OrganizationResource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param properties: The resource properties to be updated. Required. - :type properties: 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 OrganizationResource. The OrganizationResource - is compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.OrganizationResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - organization_name: str, - properties: Union[_models.OrganizationResource, JSON, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.OrganizationResource]: - """Update a OrganizationResource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param properties: The resource properties to be updated. Is one of the following types: - OrganizationResource, JSON, IO[bytes] Required. - :type properties: ~azure.mgmt.neonpostgres.models.OrganizationResource or JSON or IO[bytes] - :return: An instance of LROPoller that returns OrganizationResource. The OrganizationResource - is compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.OrganizationResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OrganizationResource] = 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._update_initial( - resource_group_name=resource_group_name, - organization_name=organization_name, - properties=properties, - 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): - response = pipeline_response.http_response - deserialized = _deserialize(_models.OrganizationResource, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OrganizationResource].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OrganizationResource]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial(self, resource_group_name: str, organization_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 = kwargs.pop("params", {}) or {} - - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_organizations_delete_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - 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.iter_bytes() - - 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, organization_name: str, **kwargs: Any) -> LROPoller[None]: - """Delete a OrganizationResource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :return: An instance of LROPoller that returns None - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - 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, - organization_name=organization_name, - 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 - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.OrganizationResource"]: - """List OrganizationResource resources by 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 OrganizationResource - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.neonpostgres.models.OrganizationResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.OrganizationResource]] = 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_organizations_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - 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 - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.OrganizationResource], deserialized.get("value", [])) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.OrganizationResource"]: - """List OrganizationResource resources by subscription ID. - - :return: An iterator like instance of OrganizationResource - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.neonpostgres.models.OrganizationResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.OrganizationResource]] = 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_organizations_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - 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 - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.OrganizationResource], deserialized.get("value", [])) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @overload - def get_postgres_versions( - self, - resource_group_name: str, - parameters: Optional[_models.PgVersion] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PgVersionsResult: - """Action to retrieve the PostgreSQL versions. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parameters: Post Action to retrieve the PostgreSQL versions. Default value is None. - :type parameters: ~azure.mgmt.neonpostgres.models.PgVersion - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PgVersionsResult. The PgVersionsResult is compatible with MutableMapping - :rtype: ~azure.mgmt.neonpostgres.models.PgVersionsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def get_postgres_versions( - self, - resource_group_name: str, - parameters: Optional[JSON] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PgVersionsResult: - """Action to retrieve the PostgreSQL versions. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parameters: Post Action to retrieve the PostgreSQL versions. Default value is None. - :type parameters: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PgVersionsResult. The PgVersionsResult is compatible with MutableMapping - :rtype: ~azure.mgmt.neonpostgres.models.PgVersionsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def get_postgres_versions( - self, - resource_group_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PgVersionsResult: - """Action to retrieve the PostgreSQL versions. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parameters: Post Action to retrieve the PostgreSQL versions. Default value is None. - :type parameters: 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: PgVersionsResult. The PgVersionsResult is compatible with MutableMapping - :rtype: ~azure.mgmt.neonpostgres.models.PgVersionsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": ["api_version", "subscription_id", "resource_group_name", "content_type", "accept"] - }, - ) - def get_postgres_versions( - self, - resource_group_name: str, - parameters: Optional[Union[_models.PgVersion, JSON, IO[bytes]]] = None, - **kwargs: Any - ) -> _models.PgVersionsResult: - """Action to retrieve the PostgreSQL versions. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parameters: Post Action to retrieve the PostgreSQL versions. Is one of the following - types: PgVersion, JSON, IO[bytes] Default value is None. - :type parameters: ~azure.mgmt.neonpostgres.models.PgVersion or JSON or IO[bytes] - :return: PgVersionsResult. The PgVersionsResult is compatible with MutableMapping - :rtype: ~azure.mgmt.neonpostgres.models.PgVersionsResult - :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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PgVersionsResult] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - if parameters is not None: - _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - else: - _content = None - - _request = build_organizations_get_postgres_versions_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = kwargs.pop("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]: - if _stream: - 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.PgVersionsResult, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class ProjectsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.neonpostgres.NeonPostgresMgmtClient`'s - :attr:`projects` attribute. - """ - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: NeonPostgresMgmtClientConfiguration = 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 - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "accept", - ] - }, - ) - def get( - self, resource_group_name: str, organization_name: str, project_name: str, **kwargs: Any - ) -> _models.Project: - """Get a Project. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :return: Project. The Project is compatible with MutableMapping - :rtype: ~azure.mgmt.neonpostgres.models.Project - :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 = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.Project] = kwargs.pop("cls", None) - - _request = build_projects_get_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = kwargs.pop("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]: - if _stream: - 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.Project, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "content_type", - "accept", - ] - }, - ) - def _create_or_update_initial( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - resource: Union[_models.Project, JSON, IO[bytes]], - **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 = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource - else: - _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_projects_create_or_update_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - subscription_id=self._config.subscription_id, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - 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.iter_bytes() - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - resource: _models.Project, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Project]: - """Create a Project. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param resource: Resource create parameters. Required. - :type resource: ~azure.mgmt.neonpostgres.models.Project - :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 Project. The Project is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Project] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - resource: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Project]: - """Create a Project. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param resource: Resource create parameters. Required. - :type resource: JSON - :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 Project. The Project is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Project] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Project]: - """Create a Project. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param resource: Resource create parameters. Required. - :type resource: 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 Project. The Project is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Project] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "content_type", - "accept", - ] - }, - ) - def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - resource: Union[_models.Project, JSON, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Project]: - """Create a Project. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param resource: Resource create parameters. Is one of the following types: Project, JSON, - IO[bytes] Required. - :type resource: ~azure.mgmt.neonpostgres.models.Project or JSON or IO[bytes] - :return: An instance of LROPoller that returns Project. The Project is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Project] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Project] = 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_or_update_initial( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - resource=resource, - 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): - response = pipeline_response.http_response - deserialized = _deserialize(_models.Project, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Project].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Project]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "content_type", - "accept", - ] - }, - ) - def _update_initial( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - properties: Union[_models.Project, JSON, IO[bytes]], - **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 = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_projects_update_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - subscription_id=self._config.subscription_id, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _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, 202]: - 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - 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.iter_bytes() - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - properties: _models.Project, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Project]: - """Update a Project. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param properties: The resource properties to be updated. Required. - :type properties: ~azure.mgmt.neonpostgres.models.Project - :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 Project. The Project is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Project] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - properties: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Project]: - """Update a Project. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param properties: The resource properties to be updated. Required. - :type properties: JSON - :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 Project. The Project is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Project] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Project]: - """Update a Project. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param properties: The resource properties to be updated. Required. - :type properties: 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 Project. The Project is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Project] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "content_type", - "accept", - ] - }, - ) - def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - properties: Union[_models.Project, JSON, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Project]: - """Update a Project. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param properties: The resource properties to be updated. Is one of the following types: - Project, JSON, IO[bytes] Required. - :type properties: ~azure.mgmt.neonpostgres.models.Project or JSON or IO[bytes] - :return: An instance of LROPoller that returns Project. The Project is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Project] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Project] = 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._update_initial( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - properties=properties, - 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): - response = pipeline_response.http_response - deserialized = _deserialize(_models.Project, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Project].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Project]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "accept", - ] - }, - ) - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, organization_name: str, project_name: str, **kwargs: Any - ) -> None: - """Delete a Project. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :return: None - :rtype: None - :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 = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_projects_delete_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "accept", - ] - }, - ) - def list(self, resource_group_name: str, organization_name: str, **kwargs: Any) -> Iterable["_models.Project"]: - """List Project resources by OrganizationResource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :return: An iterator like instance of Project - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.neonpostgres.models.Project] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.Project]] = 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_projects_list_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - 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 - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Project], deserialized.get("value", [])) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @overload - def get_connection_uri( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - connection_uri_parameters: _models.ConnectionUriProperties, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ConnectionUriProperties: - """Action to retrieve the connection URI for the Neon Database. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param connection_uri_parameters: Additional parameters for retrieving the database connection - URI. Required. - :type connection_uri_parameters: ~azure.mgmt.neonpostgres.models.ConnectionUriProperties - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ConnectionUriProperties. The ConnectionUriProperties is compatible with MutableMapping - :rtype: ~azure.mgmt.neonpostgres.models.ConnectionUriProperties - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def get_connection_uri( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - connection_uri_parameters: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ConnectionUriProperties: - """Action to retrieve the connection URI for the Neon Database. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param connection_uri_parameters: Additional parameters for retrieving the database connection - URI. Required. - :type connection_uri_parameters: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ConnectionUriProperties. The ConnectionUriProperties is compatible with MutableMapping - :rtype: ~azure.mgmt.neonpostgres.models.ConnectionUriProperties - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def get_connection_uri( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - connection_uri_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ConnectionUriProperties: - """Action to retrieve the connection URI for the Neon Database. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param connection_uri_parameters: Additional parameters for retrieving the database connection - URI. Required. - :type connection_uri_parameters: 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: ConnectionUriProperties. The ConnectionUriProperties is compatible with MutableMapping - :rtype: ~azure.mgmt.neonpostgres.models.ConnectionUriProperties - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "content_type", - "accept", - ] - }, - ) - def get_connection_uri( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - connection_uri_parameters: Union[_models.ConnectionUriProperties, JSON, IO[bytes]], - **kwargs: Any - ) -> _models.ConnectionUriProperties: - """Action to retrieve the connection URI for the Neon Database. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param connection_uri_parameters: Additional parameters for retrieving the database connection - URI. Is one of the following types: ConnectionUriProperties, JSON, IO[bytes] Required. - :type connection_uri_parameters: ~azure.mgmt.neonpostgres.models.ConnectionUriProperties or - JSON or IO[bytes] - :return: ConnectionUriProperties. The ConnectionUriProperties is compatible with MutableMapping - :rtype: ~azure.mgmt.neonpostgres.models.ConnectionUriProperties - :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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ConnectionUriProperties] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(connection_uri_parameters, (IOBase, bytes)): - _content = connection_uri_parameters - else: - _content = json.dumps(connection_uri_parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_projects_get_connection_uri_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - subscription_id=self._config.subscription_id, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = kwargs.pop("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]: - if _stream: - 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.ConnectionUriProperties, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class BranchesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.neonpostgres.NeonPostgresMgmtClient`'s - :attr:`branches` attribute. - """ - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: NeonPostgresMgmtClientConfiguration = 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 - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "accept", - ] - }, - ) - def get( - self, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, **kwargs: Any - ) -> _models.Branch: - """Get a Branch. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :return: Branch. The Branch is compatible with MutableMapping - :rtype: ~azure.mgmt.neonpostgres.models.Branch - :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 = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.Branch] = kwargs.pop("cls", None) - - _request = build_branches_get_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = kwargs.pop("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]: - if _stream: - 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.Branch, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "content_type", - "accept", - ] - }, - ) - def _create_or_update_initial( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - resource: Union[_models.Branch, JSON, IO[bytes]], - **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 = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource - else: - _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_branches_create_or_update_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - subscription_id=self._config.subscription_id, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - 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.iter_bytes() - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - resource: _models.Branch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Branch]: - """Create a Branch. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param resource: Resource create parameters. Required. - :type resource: ~azure.mgmt.neonpostgres.models.Branch - :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 Branch. The Branch is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Branch] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - resource: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Branch]: - """Create a Branch. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param resource: Resource create parameters. Required. - :type resource: JSON - :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 Branch. The Branch is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Branch] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Branch]: - """Create a Branch. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param resource: Resource create parameters. Required. - :type resource: 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 Branch. The Branch is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Branch] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "content_type", - "accept", - ] - }, - ) - def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - resource: Union[_models.Branch, JSON, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Branch]: - """Create a Branch. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param resource: Resource create parameters. Is one of the following types: Branch, JSON, - IO[bytes] Required. - :type resource: ~azure.mgmt.neonpostgres.models.Branch or JSON or IO[bytes] - :return: An instance of LROPoller that returns Branch. The Branch is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Branch] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Branch] = 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_or_update_initial( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - resource=resource, - 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): - response = pipeline_response.http_response - deserialized = _deserialize(_models.Branch, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Branch].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Branch]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "content_type", - "accept", - ] - }, - ) - def _update_initial( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - properties: Union[_models.Branch, JSON, IO[bytes]], - **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 = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_branches_update_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - subscription_id=self._config.subscription_id, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _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, 202]: - 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - 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.iter_bytes() - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - properties: _models.Branch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Branch]: - """Update a Branch. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param properties: The resource properties to be updated. Required. - :type properties: ~azure.mgmt.neonpostgres.models.Branch - :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 Branch. The Branch is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Branch] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - properties: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Branch]: - """Update a Branch. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param properties: The resource properties to be updated. Required. - :type properties: JSON - :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 Branch. The Branch is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Branch] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Branch]: - """Update a Branch. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param properties: The resource properties to be updated. Required. - :type properties: 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 Branch. The Branch is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Branch] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "content_type", - "accept", - ] - }, - ) - def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - properties: Union[_models.Branch, JSON, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Branch]: - """Update a Branch. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param properties: The resource properties to be updated. Is one of the following types: - Branch, JSON, IO[bytes] Required. - :type properties: ~azure.mgmt.neonpostgres.models.Branch or JSON or IO[bytes] - :return: An instance of LROPoller that returns Branch. The Branch is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Branch] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Branch] = 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._update_initial( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - properties=properties, - 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): - response = pipeline_response.http_response - deserialized = _deserialize(_models.Branch, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Branch].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Branch]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "accept", - ] - }, - ) - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, **kwargs: Any - ) -> None: - """Delete a Branch. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :return: None - :rtype: None - :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 = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_branches_delete_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "accept", - ] - }, - ) - def list( - self, resource_group_name: str, organization_name: str, project_name: str, **kwargs: Any - ) -> Iterable["_models.Branch"]: - """List Branch resources by Project. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :return: An iterator like instance of Branch - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.neonpostgres.models.Branch] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.Branch]] = 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_branches_list_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - 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 - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Branch], deserialized.get("value", [])) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class ComputesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.neonpostgres.NeonPostgresMgmtClient`'s - :attr:`computes` attribute. - """ - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: NeonPostgresMgmtClientConfiguration = 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 - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "compute_name", - "accept", - ] - }, - ) - def get( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - compute_name: str, - **kwargs: Any - ) -> _models.Compute: - """Get a Compute. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param compute_name: The name of the Compute. Required. - :type compute_name: str - :return: Compute. The Compute is compatible with MutableMapping - :rtype: ~azure.mgmt.neonpostgres.models.Compute - :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 = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.Compute] = kwargs.pop("cls", None) - - _request = build_computes_get_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - compute_name=compute_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = kwargs.pop("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]: - if _stream: - 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.Compute, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "compute_name", - "content_type", - "accept", - ] - }, - ) - def _create_or_update_initial( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - compute_name: str, - resource: Union[_models.Compute, JSON, IO[bytes]], - **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 = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource - else: - _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_computes_create_or_update_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - compute_name=compute_name, - subscription_id=self._config.subscription_id, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - 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.iter_bytes() - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - compute_name: str, - resource: _models.Compute, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Compute]: - """Create a Compute. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param compute_name: The name of the Compute. Required. - :type compute_name: str - :param resource: Resource create parameters. Required. - :type resource: ~azure.mgmt.neonpostgres.models.Compute - :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 Compute. The Compute is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Compute] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - compute_name: str, - resource: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Compute]: - """Create a Compute. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param compute_name: The name of the Compute. Required. - :type compute_name: str - :param resource: Resource create parameters. Required. - :type resource: JSON - :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 Compute. The Compute is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Compute] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - compute_name: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Compute]: - """Create a Compute. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param compute_name: The name of the Compute. Required. - :type compute_name: str - :param resource: Resource create parameters. Required. - :type resource: 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 Compute. The Compute is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Compute] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "compute_name", - "content_type", - "accept", - ] - }, - ) - def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - compute_name: str, - resource: Union[_models.Compute, JSON, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Compute]: - """Create a Compute. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param compute_name: The name of the Compute. Required. - :type compute_name: str - :param resource: Resource create parameters. Is one of the following types: Compute, JSON, - IO[bytes] Required. - :type resource: ~azure.mgmt.neonpostgres.models.Compute or JSON or IO[bytes] - :return: An instance of LROPoller that returns Compute. The Compute is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Compute] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Compute] = 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_or_update_initial( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - compute_name=compute_name, - resource=resource, - 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): - response = pipeline_response.http_response - deserialized = _deserialize(_models.Compute, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Compute].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Compute]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "compute_name", - "content_type", - "accept", - ] - }, - ) - def _update_initial( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - compute_name: str, - properties: Union[_models.Compute, JSON, IO[bytes]], - **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 = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_computes_update_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - compute_name=compute_name, - subscription_id=self._config.subscription_id, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _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, 202]: - 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - 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.iter_bytes() - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - compute_name: str, - properties: _models.Compute, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Compute]: - """Update a Compute. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param compute_name: The name of the Compute. Required. - :type compute_name: str - :param properties: The resource properties to be updated. Required. - :type properties: ~azure.mgmt.neonpostgres.models.Compute - :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 Compute. The Compute is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Compute] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - compute_name: str, - properties: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Compute]: - """Update a Compute. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param compute_name: The name of the Compute. Required. - :type compute_name: str - :param properties: The resource properties to be updated. Required. - :type properties: JSON - :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 Compute. The Compute is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Compute] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - compute_name: str, - properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Compute]: - """Update a Compute. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param compute_name: The name of the Compute. Required. - :type compute_name: str - :param properties: The resource properties to be updated. Required. - :type properties: 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 Compute. The Compute is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Compute] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "compute_name", - "content_type", - "accept", - ] - }, - ) - def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - compute_name: str, - properties: Union[_models.Compute, JSON, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Compute]: - """Update a Compute. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param compute_name: The name of the Compute. Required. - :type compute_name: str - :param properties: The resource properties to be updated. Is one of the following types: - Compute, JSON, IO[bytes] Required. - :type properties: ~azure.mgmt.neonpostgres.models.Compute or JSON or IO[bytes] - :return: An instance of LROPoller that returns Compute. The Compute is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Compute] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Compute] = 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._update_initial( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - compute_name=compute_name, - properties=properties, - 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): - response = pipeline_response.http_response - deserialized = _deserialize(_models.Compute, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Compute].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Compute]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "compute_name", - "accept", - ] - }, - ) - def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - compute_name: str, - **kwargs: Any - ) -> None: - """Delete a Compute. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param compute_name: The name of the Compute. Required. - :type compute_name: str - :return: None - :rtype: None - :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 = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_computes_delete_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - compute_name=compute_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "accept", - ] - }, - ) - def list( - self, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, **kwargs: Any - ) -> Iterable["_models.Compute"]: - """List Compute resources by Branch. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :return: An iterator like instance of Compute - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.neonpostgres.models.Compute] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.Compute]] = 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_computes_list_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - 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 - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Compute], deserialized.get("value", [])) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class NeonDatabasesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.neonpostgres.NeonPostgresMgmtClient`'s - :attr:`neon_databases` attribute. - """ + Instead, you should access the following operations through + :class:`~azure.mgmt.neonpostgres.NeonPostgresMgmtClient`'s + :attr:`organizations` attribute. + """ def __init__(self, *args, **kwargs): input_args = list(args) @@ -5342,45 +814,16 @@ def __init__(self, *args, **kwargs): self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "neon_database_name", - "accept", - ] - }, - ) - def get( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_database_name: str, - **kwargs: Any - ) -> _models.NeonDatabase: - """Get a NeonDatabase. + def get(self, resource_group_name: str, organization_name: str, **kwargs: Any) -> _models.OrganizationResource: + """Get a OrganizationResource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param organization_name: Name of the Neon Organizations resource. Required. :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_database_name: The name of the NeonDatabase. Required. - :type neon_database_name: str - :return: NeonDatabase. The NeonDatabase is compatible with MutableMapping - :rtype: ~azure.mgmt.neonpostgres.models.NeonDatabase + :return: OrganizationResource. The OrganizationResource is compatible with MutableMapping + :rtype: ~azure.mgmt.neonpostgres.models.OrganizationResource :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5394,14 +837,11 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.NeonDatabase] = kwargs.pop("cls", None) + cls: ClsType[_models.OrganizationResource] = kwargs.pop("cls", None) - _request = build_neon_databases_get_request( + _request = build_organizations_get_request( resource_group_name=resource_group_name, organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - neon_database_name=neon_database_name, subscription_id=self._config.subscription_id, api_version=self._config.api_version, headers=_headers, @@ -5432,37 +872,18 @@ def get( if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.NeonDatabase, response.json()) + deserialized = _deserialize(_models.OrganizationResource, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "neon_database_name", - "content_type", - "accept", - ] - }, - ) def _create_or_update_initial( self, resource_group_name: str, organization_name: str, - project_name: str, - branch_name: str, - neon_database_name: str, - resource: Union[_models.NeonDatabase, JSON, IO[bytes]], + resource: Union[_models.OrganizationResource, JSON, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -5486,12 +907,9 @@ def _create_or_update_initial( else: _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_neon_databases_create_or_update_request( + _request = build_organizations_create_or_update_request( resource_group_name=resource_group_name, organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - neon_database_name=neon_database_name, subscription_id=self._config.subscription_id, content_type=content_type, api_version=self._config.api_version, @@ -5539,35 +957,26 @@ def begin_create_or_update( self, resource_group_name: str, organization_name: str, - project_name: str, - branch_name: str, - neon_database_name: str, - resource: _models.NeonDatabase, + resource: _models.OrganizationResource, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.NeonDatabase]: - """Create a NeonDatabase. + ) -> LROPoller[_models.OrganizationResource]: + """Create a OrganizationResource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param organization_name: Name of the Neon Organizations resource. Required. :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_database_name: The name of the NeonDatabase. Required. - :type neon_database_name: str :param resource: Resource create parameters. Required. - :type resource: ~azure.mgmt.neonpostgres.models.NeonDatabase + :type resource: ~azure.mgmt.neonpostgres.models.OrganizationResource :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 NeonDatabase. The NeonDatabase is compatible - with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.NeonDatabase] + :return: An instance of LROPoller that returns OrganizationResource. The OrganizationResource + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.OrganizationResource] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -5576,35 +985,26 @@ def begin_create_or_update( self, resource_group_name: str, organization_name: str, - project_name: str, - branch_name: str, - neon_database_name: str, resource: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.NeonDatabase]: - """Create a NeonDatabase. + ) -> LROPoller[_models.OrganizationResource]: + """Create a OrganizationResource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param organization_name: Name of the Neon Organizations resource. Required. :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_database_name: The name of the NeonDatabase. Required. - :type neon_database_name: str :param resource: Resource create parameters. Required. :type resource: JSON :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 NeonDatabase. The NeonDatabase is compatible - with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.NeonDatabase] + :return: An instance of LROPoller that returns OrganizationResource. The OrganizationResource + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.OrganizationResource] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -5613,91 +1013,57 @@ def begin_create_or_update( self, resource_group_name: str, organization_name: str, - project_name: str, - branch_name: str, - neon_database_name: str, resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.NeonDatabase]: - """Create a NeonDatabase. + ) -> LROPoller[_models.OrganizationResource]: + """Create a OrganizationResource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param organization_name: Name of the Neon Organizations resource. Required. :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_database_name: The name of the NeonDatabase. Required. - :type neon_database_name: str :param resource: Resource create parameters. Required. :type resource: 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 NeonDatabase. The NeonDatabase is compatible - with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.NeonDatabase] + :return: An instance of LROPoller that returns OrganizationResource. The OrganizationResource + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.OrganizationResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "neon_database_name", - "content_type", - "accept", - ] - }, - ) def begin_create_or_update( self, resource_group_name: str, organization_name: str, - project_name: str, - branch_name: str, - neon_database_name: str, - resource: Union[_models.NeonDatabase, JSON, IO[bytes]], + resource: Union[_models.OrganizationResource, JSON, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.NeonDatabase]: - """Create a NeonDatabase. + ) -> LROPoller[_models.OrganizationResource]: + """Create a OrganizationResource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param organization_name: Name of the Neon Organizations resource. Required. :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_database_name: The name of the NeonDatabase. Required. - :type neon_database_name: str - :param resource: Resource create parameters. Is one of the following types: NeonDatabase, JSON, - IO[bytes] Required. - :type resource: ~azure.mgmt.neonpostgres.models.NeonDatabase or JSON or IO[bytes] - :return: An instance of LROPoller that returns NeonDatabase. The NeonDatabase is compatible - with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.NeonDatabase] + :param resource: Resource create parameters. Is one of the following types: + OrganizationResource, JSON, IO[bytes] Required. + :type resource: ~azure.mgmt.neonpostgres.models.OrganizationResource or JSON or IO[bytes] + :return: An instance of LROPoller that returns OrganizationResource. The OrganizationResource + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.OrganizationResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.NeonDatabase] = kwargs.pop("cls", None) + cls: ClsType[_models.OrganizationResource] = 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) @@ -5705,9 +1071,6 @@ def begin_create_or_update( raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - neon_database_name=neon_database_name, resource=resource, content_type=content_type, cls=lambda x, y, z: x, @@ -5720,7 +1083,7 @@ def begin_create_or_update( def get_long_running_output(pipeline_response): response = pipeline_response.http_response - deserialized = _deserialize(_models.NeonDatabase, response.json()) + deserialized = _deserialize(_models.OrganizationResource, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -5738,40 +1101,21 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.NeonDatabase].from_continuation_token( + return LROPoller[_models.OrganizationResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.NeonDatabase]( + return LROPoller[_models.OrganizationResource]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "neon_database_name", - "content_type", - "accept", - ] - }, - ) def _update_initial( self, resource_group_name: str, organization_name: str, - project_name: str, - branch_name: str, - neon_database_name: str, - properties: Union[_models.NeonDatabase, JSON, IO[bytes]], + properties: Union[_models.OrganizationResource, JSON, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -5795,12 +1139,9 @@ def _update_initial( else: _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_neon_databases_update_request( + _request = build_organizations_update_request( resource_group_name=resource_group_name, organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - neon_database_name=neon_database_name, subscription_id=self._config.subscription_id, content_type=content_type, api_version=self._config.api_version, @@ -5846,35 +1187,26 @@ def begin_update( self, resource_group_name: str, organization_name: str, - project_name: str, - branch_name: str, - neon_database_name: str, - properties: _models.NeonDatabase, + properties: _models.OrganizationResource, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.NeonDatabase]: - """Update a NeonDatabase. + ) -> LROPoller[_models.OrganizationResource]: + """Update a OrganizationResource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param organization_name: Name of the Neon Organizations resource. Required. :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_database_name: The name of the NeonDatabase. Required. - :type neon_database_name: str :param properties: The resource properties to be updated. Required. - :type properties: ~azure.mgmt.neonpostgres.models.NeonDatabase + :type properties: ~azure.mgmt.neonpostgres.models.OrganizationResource :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 NeonDatabase. The NeonDatabase is compatible - with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.NeonDatabase] + :return: An instance of LROPoller that returns OrganizationResource. The OrganizationResource + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.OrganizationResource] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -5883,35 +1215,26 @@ def begin_update( self, resource_group_name: str, organization_name: str, - project_name: str, - branch_name: str, - neon_database_name: str, properties: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.NeonDatabase]: - """Update a NeonDatabase. + ) -> LROPoller[_models.OrganizationResource]: + """Update a OrganizationResource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param organization_name: Name of the Neon Organizations resource. Required. :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_database_name: The name of the NeonDatabase. Required. - :type neon_database_name: str :param properties: The resource properties to be updated. Required. :type properties: JSON :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 NeonDatabase. The NeonDatabase is compatible - with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.NeonDatabase] + :return: An instance of LROPoller that returns OrganizationResource. The OrganizationResource + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.OrganizationResource] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -5920,91 +1243,57 @@ def begin_update( self, resource_group_name: str, organization_name: str, - project_name: str, - branch_name: str, - neon_database_name: str, properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.NeonDatabase]: - """Update a NeonDatabase. + ) -> LROPoller[_models.OrganizationResource]: + """Update a OrganizationResource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_database_name: The name of the NeonDatabase. Required. - :type neon_database_name: str - :param properties: The resource properties to be updated. Required. - :type properties: 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 NeonDatabase. The NeonDatabase is compatible - with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.NeonDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "neon_database_name", - "content_type", - "accept", - ] - }, - ) + :param organization_name: Name of the Neon Organizations resource. Required. + :type organization_name: str + :param properties: The resource properties to be updated. Required. + :type properties: 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 OrganizationResource. The OrganizationResource + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.OrganizationResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace def begin_update( self, resource_group_name: str, organization_name: str, - project_name: str, - branch_name: str, - neon_database_name: str, - properties: Union[_models.NeonDatabase, JSON, IO[bytes]], + properties: Union[_models.OrganizationResource, JSON, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.NeonDatabase]: - """Update a NeonDatabase. + ) -> LROPoller[_models.OrganizationResource]: + """Update a OrganizationResource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param organization_name: Name of the Neon Organizations resource. Required. :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_database_name: The name of the NeonDatabase. Required. - :type neon_database_name: str :param properties: The resource properties to be updated. Is one of the following types: - NeonDatabase, JSON, IO[bytes] Required. - :type properties: ~azure.mgmt.neonpostgres.models.NeonDatabase or JSON or IO[bytes] - :return: An instance of LROPoller that returns NeonDatabase. The NeonDatabase is compatible - with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.NeonDatabase] + OrganizationResource, JSON, IO[bytes] Required. + :type properties: ~azure.mgmt.neonpostgres.models.OrganizationResource or JSON or IO[bytes] + :return: An instance of LROPoller that returns OrganizationResource. The OrganizationResource + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.OrganizationResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.NeonDatabase] = kwargs.pop("cls", None) + cls: ClsType[_models.OrganizationResource] = 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) @@ -6012,9 +1301,6 @@ def begin_update( raw_result = self._update_initial( resource_group_name=resource_group_name, organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - neon_database_name=neon_database_name, properties=properties, content_type=content_type, cls=lambda x, y, z: x, @@ -6027,7 +1313,7 @@ def begin_update( def get_long_running_output(pipeline_response): response = pipeline_response.http_response - deserialized = _deserialize(_models.NeonDatabase, response.json()) + deserialized = _deserialize(_models.OrganizationResource, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -6045,58 +1331,17 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.NeonDatabase].from_continuation_token( + return LROPoller[_models.OrganizationResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.NeonDatabase]( + return LROPoller[_models.OrganizationResource]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "neon_database_name", - "accept", - ] - }, - ) - def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_database_name: str, - **kwargs: Any - ) -> None: - """Delete a NeonDatabase. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_database_name: The name of the NeonDatabase. Required. - :type neon_database_name: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ + def _delete_initial(self, resource_group_name: str, organization_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6108,14 +1353,11 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_neon_databases_delete_request( + _request = build_organizations_delete_request( resource_group_name=resource_group_name, organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - neon_database_name=neon_database_name, subscription_id=self._config.subscription_id, api_version=self._config.api_version, headers=_headers, @@ -6126,58 +1368,193 @@ def delete( # pylint: disable=inconsistent-return-statements } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _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, 204]: + 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) 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.iter_bytes() + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "accept", - ] - }, - ) - def list( - self, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, **kwargs: Any - ) -> Iterable["_models.NeonDatabase"]: - """List NeonDatabase resources by Branch. + def begin_delete(self, resource_group_name: str, organization_name: str, **kwargs: Any) -> LROPoller[None]: + """Delete a OrganizationResource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param organization_name: Name of the Neon Organizations resource. Required. :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :return: An iterator like instance of NeonDatabase - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.neonpostgres.models.NeonDatabase] + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + organization_name=organization_name, + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.OrganizationResource"]: + """List OrganizationResource resources by 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 OrganizationResource + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.neonpostgres.models.OrganizationResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.OrganizationResource]] = 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_organizations_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.OrganizationResource], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.OrganizationResource"]: + """List OrganizationResource resources by subscription ID. + + :return: An iterator like instance of OrganizationResource + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.neonpostgres.models.OrganizationResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.NeonDatabase]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.OrganizationResource]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -6190,11 +1567,7 @@ def list( def prepare_request(next_link=None): if not next_link: - _request = build_neon_databases_list_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, + _request = build_organizations_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=self._config.api_version, headers=_headers, @@ -6231,7 +1604,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.NeonDatabase], deserialized.get("value", [])) + list_of_elem = _deserialize(List[_models.OrganizationResource], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -6254,148 +1627,103 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - -class NeonRolesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.neonpostgres.NeonPostgresMgmtClient`'s - :attr:`neon_roles` attribute. - """ - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: NeonPostgresMgmtClientConfiguration = 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 - @api_version_validation( - method_added_on="2025-03-01-preview", - params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "neon_role_name", - "accept", - ] - }, - ) - def get( + @overload + def get_postgres_versions( self, resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_role_name: str, + parameters: Optional[_models.PgVersion] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> _models.NeonRole: - """Get a NeonRole. + ) -> _models.PgVersionsResult: + """Action to retrieve the PostgreSQL versions. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_role_name: The name of the NeonRole. Required. - :type neon_role_name: str - :return: NeonRole. The NeonRole is compatible with MutableMapping - :rtype: ~azure.mgmt.neonpostgres.models.NeonRole + :param parameters: Post Action to retrieve the PostgreSQL versions. Default value is None. + :type parameters: ~azure.mgmt.neonpostgres.models.PgVersion + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PgVersionsResult. The PgVersionsResult is compatible with MutableMapping + :rtype: ~azure.mgmt.neonpostgres.models.PgVersionsResult :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 = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.NeonRole] = kwargs.pop("cls", None) - - _request = build_neon_roles_get_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - neon_role_name=neon_role_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = kwargs.pop("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]: - if _stream: - 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + @overload + def get_postgres_versions( + self, + resource_group_name: str, + parameters: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PgVersionsResult: + """Action to retrieve the PostgreSQL versions. - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.NeonRole, response.json()) + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: Post Action to retrieve the PostgreSQL versions. Default value is None. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PgVersionsResult. The PgVersionsResult is compatible with MutableMapping + :rtype: ~azure.mgmt.neonpostgres.models.PgVersionsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + @overload + def get_postgres_versions( + self, + resource_group_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PgVersionsResult: + """Action to retrieve the PostgreSQL versions. - return deserialized # type: ignore + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: Post Action to retrieve the PostgreSQL versions. Default value is None. + :type parameters: 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: PgVersionsResult. The PgVersionsResult is compatible with MutableMapping + :rtype: ~azure.mgmt.neonpostgres.models.PgVersionsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace @api_version_validation( method_added_on="2025-03-01-preview", params_added_on={ - "2025-03-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "organization_name", - "project_name", - "branch_name", - "neon_role_name", - "content_type", - "accept", - ] + "2025-03-01-preview": ["api_version", "subscription_id", "resource_group_name", "content_type", "accept"] }, ) - def _create_or_update_initial( + def get_postgres_versions( self, resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_role_name: str, - resource: Union[_models.NeonRole, JSON, IO[bytes]], + parameters: Optional[Union[_models.PgVersion, JSON, IO[bytes]]] = None, **kwargs: Any - ) -> Iterator[bytes]: + ) -> _models.PgVersionsResult: + """Action to retrieve the PostgreSQL versions. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: Post Action to retrieve the PostgreSQL versions. Is one of the following + types: PgVersion, JSON, IO[bytes] Default value is None. + :type parameters: ~azure.mgmt.neonpostgres.models.PgVersion or JSON or IO[bytes] + :return: PgVersionsResult. The PgVersionsResult is compatible with MutableMapping + :rtype: ~azure.mgmt.neonpostgres.models.PgVersionsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6408,21 +1736,20 @@ def _create_or_update_initial( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[_models.PgVersionsResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource + if isinstance(parameters, (IOBase, bytes)): + _content = parameters else: - _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + if parameters is not None: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None - _request = build_neon_roles_create_or_update_request( + _request = build_organizations_get_postgres_versions_request( resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - neon_role_name=neon_role_name, subscription_id=self._config.subscription_id, content_type=content_type, api_version=self._config.api_version, @@ -6435,146 +1762,50 @@ def _create_or_update_initial( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = True + _stream = kwargs.pop("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, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: + if _stream: + 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) 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.iter_bytes() - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_role_name: str, - resource: _models.NeonRole, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.NeonRole]: - """Create a NeonRole. + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.PgVersionsResult, response.json()) - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_role_name: The name of the NeonRole. Required. - :type neon_role_name: str - :param resource: Resource create parameters. Required. - :type resource: ~azure.mgmt.neonpostgres.models.NeonRole - :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 NeonRole. The NeonRole is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.NeonRole] - :raises ~azure.core.exceptions.HttpResponseError: - """ + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - @overload - def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_role_name: str, - resource: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.NeonRole]: - """Create a NeonRole. + return deserialized # type: ignore - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_role_name: The name of the NeonRole. Required. - :type neon_role_name: str - :param resource: Resource create parameters. Required. - :type resource: JSON - :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 NeonRole. The NeonRole is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.NeonRole] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @overload - def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_role_name: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.NeonRole]: - """Create a NeonRole. +class ProjectsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_role_name: The name of the NeonRole. Required. - :type neon_role_name: str - :param resource: Resource create parameters. Required. - :type resource: 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 NeonRole. The NeonRole is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.NeonRole] - :raises ~azure.core.exceptions.HttpResponseError: - """ + Instead, you should access the following operations through + :class:`~azure.mgmt.neonpostgres.NeonPostgresMgmtClient`'s + :attr:`projects` attribute. + """ + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: NeonPostgresMgmtClientConfiguration = 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 @api_version_validation( @@ -6586,24 +1817,14 @@ def begin_create_or_update( "resource_group_name", "organization_name", "project_name", - "branch_name", - "neon_role_name", - "content_type", "accept", ] }, ) - def begin_create_or_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_role_name: str, - resource: Union[_models.NeonRole, JSON, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.NeonRole]: - """Create a NeonRole. + def get( + self, resource_group_name: str, organization_name: str, project_name: str, **kwargs: Any + ) -> _models.Project: + """Get a Project. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -6612,73 +1833,64 @@ def begin_create_or_update( :type organization_name: str :param project_name: The name of the Project. Required. :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_role_name: The name of the NeonRole. Required. - :type neon_role_name: str - :param resource: Resource create parameters. Is one of the following types: NeonRole, JSON, - IO[bytes] Required. - :type resource: ~azure.mgmt.neonpostgres.models.NeonRole or JSON or IO[bytes] - :return: An instance of LROPoller that returns NeonRole. The NeonRole is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.NeonRole] + :return: Project. The Project is compatible with MutableMapping + :rtype: ~azure.mgmt.neonpostgres.models.Project :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.NeonRole] = 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_or_update_initial( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - neon_role_name=neon_role_name, - resource=resource, - 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) + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = _deserialize(_models.NeonRole, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + cls: ClsType[_models.Project] = kwargs.pop("cls", None) + _request = build_projects_get_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) path_format_arguments = { "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.NeonRole].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.NeonRole]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Project, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + @api_version_validation( method_added_on="2025-03-01-preview", params_added_on={ @@ -6688,21 +1900,17 @@ def get_long_running_output(pipeline_response): "resource_group_name", "organization_name", "project_name", - "branch_name", - "neon_role_name", "content_type", "accept", ] }, ) - def _update_initial( + def _create_or_update_initial( self, resource_group_name: str, organization_name: str, project_name: str, - branch_name: str, - neon_role_name: str, - properties: Union[_models.NeonRole, JSON, IO[bytes]], + resource: Union[_models.Project, JSON, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -6721,17 +1929,15 @@ def _update_initial( content_type = content_type or "application/json" _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties + if isinstance(resource, (IOBase, bytes)): + _content = resource else: - _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_neon_roles_update_request( + _request = build_projects_create_or_update_request( resource_group_name=resource_group_name, organization_name=organization_name, project_name=project_name, - branch_name=branch_name, - neon_role_name=neon_role_name, subscription_id=self._config.subscription_id, content_type=content_type, api_version=self._config.api_version, @@ -6751,7 +1957,7 @@ def _update_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200, 201]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -6761,8 +1967,10 @@ def _update_initial( 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")) + 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.iter_bytes() @@ -6773,19 +1981,17 @@ def _update_initial( return deserialized # type: ignore @overload - def begin_update( + def begin_create_or_update( self, resource_group_name: str, organization_name: str, project_name: str, - branch_name: str, - neon_role_name: str, - properties: _models.NeonRole, + resource: _models.Project, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.NeonRole]: - """Update a NeonRole. + ) -> LROPoller[_models.Project]: + """Create a Project. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -6794,35 +2000,29 @@ def begin_update( :type organization_name: str :param project_name: The name of the Project. Required. :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_role_name: The name of the NeonRole. Required. - :type neon_role_name: str - :param properties: The resource properties to be updated. Required. - :type properties: ~azure.mgmt.neonpostgres.models.NeonRole + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.neonpostgres.models.Project :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 NeonRole. The NeonRole is compatible with + :return: An instance of LROPoller that returns Project. The Project is compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.NeonRole] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Project] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_update( + def begin_create_or_update( self, resource_group_name: str, organization_name: str, project_name: str, - branch_name: str, - neon_role_name: str, - properties: JSON, + resource: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.NeonRole]: - """Update a NeonRole. + ) -> LROPoller[_models.Project]: + """Create a Project. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -6831,35 +2031,29 @@ def begin_update( :type organization_name: str :param project_name: The name of the Project. Required. :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_role_name: The name of the NeonRole. Required. - :type neon_role_name: str - :param properties: The resource properties to be updated. Required. - :type properties: JSON + :param resource: Resource create parameters. Required. + :type resource: JSON :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 NeonRole. The NeonRole is compatible with + :return: An instance of LROPoller that returns Project. The Project is compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.NeonRole] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Project] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_update( + def begin_create_or_update( self, resource_group_name: str, organization_name: str, project_name: str, - branch_name: str, - neon_role_name: str, - properties: IO[bytes], + resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.NeonRole]: - """Update a NeonRole. + ) -> LROPoller[_models.Project]: + """Create a Project. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -6867,19 +2061,15 @@ def begin_update( :param organization_name: Name of the Neon Organizations resource. Required. :type organization_name: str :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_role_name: The name of the NeonRole. Required. - :type neon_role_name: str - :param properties: The resource properties to be updated. Required. - :type properties: IO[bytes] + :type project_name: str + :param resource: Resource create parameters. Required. + :type resource: 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 NeonRole. The NeonRole is compatible with + :return: An instance of LROPoller that returns Project. The Project is compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.NeonRole] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Project] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -6893,24 +2083,20 @@ def begin_update( "resource_group_name", "organization_name", "project_name", - "branch_name", - "neon_role_name", "content_type", "accept", ] }, ) - def begin_update( + def begin_create_or_update( self, resource_group_name: str, organization_name: str, project_name: str, - branch_name: str, - neon_role_name: str, - properties: Union[_models.NeonRole, JSON, IO[bytes]], + resource: Union[_models.Project, JSON, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.NeonRole]: - """Update a NeonRole. + ) -> LROPoller[_models.Project]: + """Create a Project. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -6919,34 +2105,28 @@ def begin_update( :type organization_name: str :param project_name: The name of the Project. Required. :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_role_name: The name of the NeonRole. Required. - :type neon_role_name: str - :param properties: The resource properties to be updated. Is one of the following types: - NeonRole, JSON, IO[bytes] Required. - :type properties: ~azure.mgmt.neonpostgres.models.NeonRole or JSON or IO[bytes] - :return: An instance of LROPoller that returns NeonRole. The NeonRole is compatible with + :param resource: Resource create parameters. Is one of the following types: Project, JSON, + IO[bytes] Required. + :type resource: ~azure.mgmt.neonpostgres.models.Project or JSON or IO[bytes] + :return: An instance of LROPoller that returns Project. The Project is compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.NeonRole] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Project] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.NeonRole] = kwargs.pop("cls", None) + cls: ClsType[_models.Project] = 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._update_initial( + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, organization_name=organization_name, project_name=project_name, - branch_name=branch_name, - neon_role_name=neon_role_name, - properties=properties, + resource=resource, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, @@ -6958,7 +2138,7 @@ def begin_update( def get_long_running_output(pipeline_response): response = pipeline_response.http_response - deserialized = _deserialize(_models.NeonRole, response.json()) + deserialized = _deserialize(_models.Project, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -6976,13 +2156,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.NeonRole].from_continuation_token( + return LROPoller[_models.Project].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.NeonRole]( + return LROPoller[_models.Project]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) @@ -6996,22 +2176,14 @@ def get_long_running_output(pipeline_response): "resource_group_name", "organization_name", "project_name", - "branch_name", - "neon_role_name", "accept", ] }, ) def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - neon_role_name: str, - **kwargs: Any + self, resource_group_name: str, organization_name: str, project_name: str, **kwargs: Any ) -> None: - """Delete a NeonRole. + """Delete a Project. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -7020,10 +2192,6 @@ def delete( # pylint: disable=inconsistent-return-statements :type organization_name: str :param project_name: The name of the Project. Required. :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param neon_role_name: The name of the NeonRole. Required. - :type neon_role_name: str :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -7041,12 +2209,10 @@ def delete( # pylint: disable=inconsistent-return-statements cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_neon_roles_delete_request( + _request = build_projects_delete_request( resource_group_name=resource_group_name, organization_name=organization_name, project_name=project_name, - branch_name=branch_name, - neon_role_name=neon_role_name, subscription_id=self._config.subscription_id, api_version=self._config.api_version, headers=_headers, @@ -7081,34 +2247,26 @@ def delete( # pylint: disable=inconsistent-return-statements "subscription_id", "resource_group_name", "organization_name", - "project_name", - "branch_name", "accept", ] }, ) - def list( - self, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, **kwargs: Any - ) -> Iterable["_models.NeonRole"]: - """List NeonRole resources by Branch. + def list(self, resource_group_name: str, organization_name: str, **kwargs: Any) -> Iterable["_models.Project"]: + """List Project resources by OrganizationResource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param organization_name: Name of the Neon Organizations resource. Required. :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :return: An iterator like instance of NeonRole - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.neonpostgres.models.NeonRole] + :return: An iterator like instance of Project + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.neonpostgres.models.Project] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.NeonRole]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.Project]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -7121,11 +2279,9 @@ def list( def prepare_request(next_link=None): if not next_link: - _request = build_neon_roles_list_request( + _request = build_projects_list_request( resource_group_name=resource_group_name, organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, subscription_id=self._config.subscription_id, api_version=self._config.api_version, headers=_headers, @@ -7162,7 +2318,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.NeonRole], deserialized.get("value", [])) + list_of_elem = _deserialize(List[_models.Project], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -7181,19 +2337,216 @@ def get_next(next_link=None): error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return pipeline_response + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @overload + def get_connection_uri( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + connection_uri_parameters: _models.ConnectionUriProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectionUriProperties: + """Action to retrieve the connection URI for the Neon Database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Neon Organizations resource. Required. + :type organization_name: str + :param project_name: The name of the Project. Required. + :type project_name: str + :param connection_uri_parameters: Additional parameters for retrieving the database connection + URI. Required. + :type connection_uri_parameters: ~azure.mgmt.neonpostgres.models.ConnectionUriProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ConnectionUriProperties. The ConnectionUriProperties is compatible with MutableMapping + :rtype: ~azure.mgmt.neonpostgres.models.ConnectionUriProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def get_connection_uri( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + connection_uri_parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectionUriProperties: + """Action to retrieve the connection URI for the Neon Database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Neon Organizations resource. Required. + :type organization_name: str + :param project_name: The name of the Project. Required. + :type project_name: str + :param connection_uri_parameters: Additional parameters for retrieving the database connection + URI. Required. + :type connection_uri_parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ConnectionUriProperties. The ConnectionUriProperties is compatible with MutableMapping + :rtype: ~azure.mgmt.neonpostgres.models.ConnectionUriProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def get_connection_uri( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + connection_uri_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectionUriProperties: + """Action to retrieve the connection URI for the Neon Database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Neon Organizations resource. Required. + :type organization_name: str + :param project_name: The name of the Project. Required. + :type project_name: str + :param connection_uri_parameters: Additional parameters for retrieving the database connection + URI. Required. + :type connection_uri_parameters: 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: ConnectionUriProperties. The ConnectionUriProperties is compatible with MutableMapping + :rtype: ~azure.mgmt.neonpostgres.models.ConnectionUriProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + @api_version_validation( + method_added_on="2025-03-01-preview", + params_added_on={ + "2025-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + "content_type", + "accept", + ] + }, + ) + def get_connection_uri( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + connection_uri_parameters: Union[_models.ConnectionUriProperties, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ConnectionUriProperties: + """Action to retrieve the connection URI for the Neon Database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Neon Organizations resource. Required. + :type organization_name: str + :param project_name: The name of the Project. Required. + :type project_name: str + :param connection_uri_parameters: Additional parameters for retrieving the database connection + URI. Is one of the following types: ConnectionUriProperties, JSON, IO[bytes] Required. + :type connection_uri_parameters: ~azure.mgmt.neonpostgres.models.ConnectionUriProperties or + JSON or IO[bytes] + :return: ConnectionUriProperties. The ConnectionUriProperties is compatible with MutableMapping + :rtype: ~azure.mgmt.neonpostgres.models.ConnectionUriProperties + :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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectionUriProperties] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(connection_uri_parameters, (IOBase, bytes)): + _content = connection_uri_parameters + else: + _content = json.dumps(connection_uri_parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_projects_get_connection_uri_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.ConnectionUriProperties, response.json()) - return ItemPaged(get_next, extract_data) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore -class EndpointsOperations: +class BranchesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.neonpostgres.NeonPostgresMgmtClient`'s - :attr:`endpoints` attribute. + :attr:`branches` attribute. """ def __init__(self, *args, **kwargs): @@ -7214,21 +2567,14 @@ def __init__(self, *args, **kwargs): "organization_name", "project_name", "branch_name", - "endpoint_name", "accept", ] }, ) def get( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - endpoint_name: str, - **kwargs: Any - ) -> _models.Endpoint: - """Get a Endpoint. + self, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, **kwargs: Any + ) -> _models.Branch: + """Get a Branch. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -7239,10 +2585,8 @@ def get( :type project_name: str :param branch_name: The name of the Branch. Required. :type branch_name: str - :param endpoint_name: The name of the Endpoint. Required. - :type endpoint_name: str - :return: Endpoint. The Endpoint is compatible with MutableMapping - :rtype: ~azure.mgmt.neonpostgres.models.Endpoint + :return: Branch. The Branch is compatible with MutableMapping + :rtype: ~azure.mgmt.neonpostgres.models.Branch :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -7256,14 +2600,13 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) + cls: ClsType[_models.Branch] = kwargs.pop("cls", None) - _request = build_endpoints_get_request( + _request = build_branches_get_request( resource_group_name=resource_group_name, organization_name=organization_name, project_name=project_name, branch_name=branch_name, - endpoint_name=endpoint_name, subscription_id=self._config.subscription_id, api_version=self._config.api_version, headers=_headers, @@ -7294,7 +2637,7 @@ def get( if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.Endpoint, response.json()) + deserialized = _deserialize(_models.Branch, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -7311,7 +2654,6 @@ def get( "organization_name", "project_name", "branch_name", - "endpoint_name", "content_type", "accept", ] @@ -7323,8 +2665,7 @@ def _create_or_update_initial( organization_name: str, project_name: str, branch_name: str, - endpoint_name: str, - resource: Union[_models.Endpoint, JSON, IO[bytes]], + resource: Union[_models.Branch, JSON, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -7348,12 +2689,11 @@ def _create_or_update_initial( else: _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_endpoints_create_or_update_request( + _request = build_branches_create_or_update_request( resource_group_name=resource_group_name, organization_name=organization_name, project_name=project_name, branch_name=branch_name, - endpoint_name=endpoint_name, subscription_id=self._config.subscription_id, content_type=content_type, api_version=self._config.api_version, @@ -7403,13 +2743,12 @@ def begin_create_or_update( organization_name: str, project_name: str, branch_name: str, - endpoint_name: str, - resource: _models.Endpoint, + resource: _models.Branch, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.Endpoint]: - """Create a Endpoint. + ) -> LROPoller[_models.Branch]: + """Create a Branch. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -7420,16 +2759,14 @@ def begin_create_or_update( :type project_name: str :param branch_name: The name of the Branch. Required. :type branch_name: str - :param endpoint_name: The name of the Endpoint. Required. - :type endpoint_name: str :param resource: Resource create parameters. Required. - :type resource: ~azure.mgmt.neonpostgres.models.Endpoint + :type resource: ~azure.mgmt.neonpostgres.models.Branch :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 Endpoint. The Endpoint is compatible with + :return: An instance of LROPoller that returns Branch. The Branch is compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Endpoint] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Branch] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -7440,13 +2777,12 @@ def begin_create_or_update( organization_name: str, project_name: str, branch_name: str, - endpoint_name: str, resource: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.Endpoint]: - """Create a Endpoint. + ) -> LROPoller[_models.Branch]: + """Create a Branch. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -7457,16 +2793,14 @@ def begin_create_or_update( :type project_name: str :param branch_name: The name of the Branch. Required. :type branch_name: str - :param endpoint_name: The name of the Endpoint. Required. - :type endpoint_name: str :param resource: Resource create parameters. Required. :type resource: JSON :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 Endpoint. The Endpoint is compatible with + :return: An instance of LROPoller that returns Branch. The Branch is compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Endpoint] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Branch] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -7477,13 +2811,12 @@ def begin_create_or_update( organization_name: str, project_name: str, branch_name: str, - endpoint_name: str, resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.Endpoint]: - """Create a Endpoint. + ) -> LROPoller[_models.Branch]: + """Create a Branch. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -7494,16 +2827,14 @@ def begin_create_or_update( :type project_name: str :param branch_name: The name of the Branch. Required. :type branch_name: str - :param endpoint_name: The name of the Endpoint. Required. - :type endpoint_name: str :param resource: Resource create parameters. Required. :type resource: 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 Endpoint. The Endpoint is compatible with + :return: An instance of LROPoller that returns Branch. The Branch is compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Endpoint] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Branch] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -7518,7 +2849,6 @@ def begin_create_or_update( "organization_name", "project_name", "branch_name", - "endpoint_name", "content_type", "accept", ] @@ -7530,11 +2860,10 @@ def begin_create_or_update( organization_name: str, project_name: str, branch_name: str, - endpoint_name: str, - resource: Union[_models.Endpoint, JSON, IO[bytes]], + resource: Union[_models.Branch, JSON, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.Endpoint]: - """Create a Endpoint. + ) -> LROPoller[_models.Branch]: + """Create a Branch. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -7545,21 +2874,19 @@ def begin_create_or_update( :type project_name: str :param branch_name: The name of the Branch. Required. :type branch_name: str - :param endpoint_name: The name of the Endpoint. Required. - :type endpoint_name: str - :param resource: Resource create parameters. Is one of the following types: Endpoint, JSON, + :param resource: Resource create parameters. Is one of the following types: Branch, JSON, IO[bytes] Required. - :type resource: ~azure.mgmt.neonpostgres.models.Endpoint or JSON or IO[bytes] - :return: An instance of LROPoller that returns Endpoint. The Endpoint is compatible with + :type resource: ~azure.mgmt.neonpostgres.models.Branch or JSON or IO[bytes] + :return: An instance of LROPoller that returns Branch. The Branch is compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Endpoint] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Branch] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) + cls: ClsType[_models.Branch] = 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) @@ -7569,7 +2896,6 @@ def begin_create_or_update( organization_name=organization_name, project_name=project_name, branch_name=branch_name, - endpoint_name=endpoint_name, resource=resource, content_type=content_type, cls=lambda x, y, z: x, @@ -7582,7 +2908,7 @@ def begin_create_or_update( def get_long_running_output(pipeline_response): response = pipeline_response.http_response - deserialized = _deserialize(_models.Endpoint, response.json()) + deserialized = _deserialize(_models.Branch, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -7600,16 +2926,220 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.Endpoint].from_continuation_token( + return LROPoller[_models.Branch].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.Endpoint]( + return LROPoller[_models.Branch]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) + @distributed_trace + @api_version_validation( + method_added_on="2025-03-01-preview", + params_added_on={ + "2025-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + "branch_name", + "accept", + ] + }, + ) + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, **kwargs: Any + ) -> None: + """Delete a Branch. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Neon Organizations resource. Required. + :type organization_name: str + :param project_name: The name of the Project. Required. + :type project_name: str + :param branch_name: The name of the Branch. Required. + :type branch_name: str + :return: None + :rtype: None + :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 = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_branches_delete_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_name, + branch_name=branch_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="2025-03-01-preview", + params_added_on={ + "2025-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + "accept", + ] + }, + ) + def list( + self, resource_group_name: str, organization_name: str, project_name: str, **kwargs: Any + ) -> Iterable["_models.Branch"]: + """List Branch resources by Project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Neon Organizations resource. Required. + :type organization_name: str + :param project_name: The name of the Project. Required. + :type project_name: str + :return: An iterator like instance of Branch + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.neonpostgres.models.Branch] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Branch]] = 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_branches_list_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Branch], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ComputesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.neonpostgres.NeonPostgresMgmtClient`'s + :attr:`computes` attribute. + """ + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: NeonPostgresMgmtClientConfiguration = 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 @api_version_validation( method_added_on="2025-03-01-preview", params_added_on={ @@ -7620,22 +3150,33 @@ def get_long_running_output(pipeline_response): "organization_name", "project_name", "branch_name", - "endpoint_name", - "content_type", "accept", ] }, ) - def _update_initial( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - endpoint_name: str, - properties: Union[_models.Endpoint, JSON, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: + def list( + self, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, **kwargs: Any + ) -> Iterable["_models.Compute"]: + """List Compute resources by Branch. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Neon Organizations resource. Required. + :type organization_name: str + :param project_name: The name of the Project. Required. + :type project_name: str + :param branch_name: The name of the Branch. Required. + :type branch_name: str + :return: An iterator like instance of Compute + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.neonpostgres.models.Compute] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Compute]] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -7644,175 +3185,90 @@ def _update_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_endpoints_update_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + def prepare_request(next_link=None): + if not next_link: - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + _request = build_computes_list_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_name, + branch_name=branch_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - response = pipeline_response.http_response + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - if response.status_code not in [200, 202]: - 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + return _request - 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")) + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Compute], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) - deserialized = response.iter_bytes() + def get_next(next_link=None): + _request = prepare_request(next_link) - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - return deserialized # type: ignore + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - @overload - def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - endpoint_name: str, - properties: _models.Endpoint, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Endpoint]: - """Update a Endpoint. + return pipeline_response - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param endpoint_name: The name of the Endpoint. Required. - :type endpoint_name: str - :param properties: The resource properties to be updated. Required. - :type properties: ~azure.mgmt.neonpostgres.models.Endpoint - :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 Endpoint. The Endpoint is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Endpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ + return ItemPaged(get_next, extract_data) - @overload - def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - endpoint_name: str, - properties: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Endpoint]: - """Update a Endpoint. - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param endpoint_name: The name of the Endpoint. Required. - :type endpoint_name: str - :param properties: The resource properties to be updated. Required. - :type properties: JSON - :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 Endpoint. The Endpoint is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Endpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ +class NeonDatabasesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - @overload - def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - endpoint_name: str, - properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Endpoint]: - """Update a Endpoint. + Instead, you should access the following operations through + :class:`~azure.mgmt.neonpostgres.NeonPostgresMgmtClient`'s + :attr:`neon_databases` attribute. + """ - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param organization_name: Name of the Neon Organizations resource. Required. - :type organization_name: str - :param project_name: The name of the Project. Required. - :type project_name: str - :param branch_name: The name of the Branch. Required. - :type branch_name: str - :param endpoint_name: The name of the Endpoint. Required. - :type endpoint_name: str - :param properties: The resource properties to be updated. Required. - :type properties: 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 Endpoint. The Endpoint is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Endpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: NeonPostgresMgmtClientConfiguration = 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 @api_version_validation( @@ -7825,23 +3281,14 @@ def begin_update( "organization_name", "project_name", "branch_name", - "endpoint_name", - "content_type", "accept", ] }, ) - def begin_update( - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - endpoint_name: str, - properties: Union[_models.Endpoint, JSON, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Endpoint]: - """Update a Endpoint. + def list( + self, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, **kwargs: Any + ) -> Iterable["_models.NeonDatabase"]: + """List NeonDatabase resources by Branch. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -7852,70 +3299,107 @@ def begin_update( :type project_name: str :param branch_name: The name of the Branch. Required. :type branch_name: str - :param endpoint_name: The name of the Endpoint. Required. - :type endpoint_name: str - :param properties: The resource properties to be updated. Is one of the following types: - Endpoint, JSON, IO[bytes] Required. - :type properties: ~azure.mgmt.neonpostgres.models.Endpoint or JSON or IO[bytes] - :return: An instance of LROPoller that returns Endpoint. The Endpoint is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.Endpoint] + :return: An iterator like instance of NeonDatabase + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.neonpostgres.models.NeonDatabase] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Endpoint] = 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._update_initial( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - endpoint_name=endpoint_name, - properties=properties, - 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) + cls: ClsType[List[_models.NeonDatabase]] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = _deserialize(_models.Endpoint, response.json()) + 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_neon_databases_list_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_name, + branch_name=branch_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.NeonDatabase], deserialized.get("value", [])) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } + def get_next(next_link=None): + _request = prepare_request(next_link) - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Endpoint].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - return LROPoller[_models.Endpoint]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class NeonRolesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.neonpostgres.NeonPostgresMgmtClient`'s + :attr:`neon_roles` attribute. + """ + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: NeonPostgresMgmtClientConfiguration = 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 @api_version_validation( @@ -7928,21 +3412,14 @@ def get_long_running_output(pipeline_response): "organization_name", "project_name", "branch_name", - "endpoint_name", "accept", ] }, ) - def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - organization_name: str, - project_name: str, - branch_name: str, - endpoint_name: str, - **kwargs: Any - ) -> None: - """Delete a Endpoint. + def list( + self, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, **kwargs: Any + ) -> Iterable["_models.NeonRole"]: + """List NeonRole resources by Branch. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -7953,12 +3430,15 @@ def delete( # pylint: disable=inconsistent-return-statements :type project_name: str :param branch_name: The name of the Branch. Required. :type branch_name: str - :param endpoint_name: The name of the Endpoint. Required. - :type endpoint_name: str - :return: None - :rtype: None + :return: An iterator like instance of NeonRole + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.neonpostgres.models.NeonRole] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.NeonRole]] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -7967,41 +3447,90 @@ def delete( # pylint: disable=inconsistent-return-statements } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} + def prepare_request(next_link=None): + if not next_link: - cls: ClsType[None] = kwargs.pop("cls", None) + _request = build_neon_roles_list_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_name, + branch_name=branch_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _request = build_endpoints_delete_request( - resource_group_name=resource_group_name, - organization_name=organization_name, - project_name=project_name, - branch_name=branch_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + return _request - response = pipeline_response.http_response + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.NeonRole], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.ErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + def get_next(next_link=None): + _request = prepare_request(next_link) - if cls: - return cls(pipeline_response, None, {}) # type: ignore + _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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class EndpointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.neonpostgres.NeonPostgresMgmtClient`'s + :attr:`endpoints` attribute. + """ + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: NeonPostgresMgmtClientConfiguration = 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 @api_version_validation( diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/branches_create_or_update_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/branches_create_or_update_maximum_set_gen.py index e883b62b7bfd..d8de277d6a7b 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/branches_create_or_update_maximum_set_gen.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/branches_create_or_update_maximum_set_gen.py @@ -32,9 +32,9 @@ def main(): response = client.branches.begin_create_or_update( resource_group_name="rgneon", - organization_name="test-org", - project_name="test-entity", - branch_name="test-entity", + organization_name="contoso-org", + project_name="sample-resource", + branch_name="sample-resource", resource={ "properties": { "attributes": [{"name": "trhvzyvaqy", "value": "evpkgsskyavybxwwssm"}], diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/branches_delete_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/branches_delete_maximum_set_gen.py index 8c6726fbd18e..bf84e630474c 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/branches_delete_maximum_set_gen.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/branches_delete_maximum_set_gen.py @@ -32,9 +32,9 @@ def main(): client.branches.delete( resource_group_name="rgneon", - organization_name="test-org", - project_name="entity-name", - branch_name="entity-name", + organization_name="contoso-org", + project_name="sample-resource", + branch_name="sample-resource", ) diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/branches_get_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/branches_get_maximum_set_gen.py index d2d1fcc370df..f9752095967a 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/branches_get_maximum_set_gen.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/branches_get_maximum_set_gen.py @@ -32,9 +32,9 @@ def main(): response = client.branches.get( resource_group_name="rgneon", - organization_name="test-org", - project_name="entity-name", - branch_name="entity-name", + organization_name="contoso-org", + project_name="sample-resource", + branch_name="sample-resource", ) print(response) diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/branches_list_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/branches_list_maximum_set_gen.py index de202ec70c69..44aeda341dbe 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/branches_list_maximum_set_gen.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/branches_list_maximum_set_gen.py @@ -32,8 +32,8 @@ def main(): response = client.branches.list( resource_group_name="rgneon", - organization_name="test-org", - project_name="entity-name", + organization_name="contoso-org", + project_name="sample-resource", ) for item in response: print(item) diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/branches_update_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/branches_update_maximum_set_gen.py deleted file mode 100644 index b227f4a49c23..000000000000 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/branches_update_maximum_set_gen.py +++ /dev/null @@ -1,80 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.neonpostgres import NeonPostgresMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-neonpostgres -# USAGE - python branches_update_maximum_set_gen.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 = NeonPostgresMgmtClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.branches.begin_update( - resource_group_name="rgneon", - organization_name="test-org", - project_name="entity-name", - branch_name="entity-name", - properties={ - "properties": { - "attributes": [{"name": "trhvzyvaqy", "value": "evpkgsskyavybxwwssm"}], - "databaseName": "duhxebzhd", - "databases": [ - { - "attributes": [{"name": "trhvzyvaqy", "value": "evpkgsskyavybxwwssm"}], - "branchId": "orfdwdmzvfvlnrgussvcvoek", - "entityName": "entity-name", - "ownerName": "odmbeg", - } - ], - "endpoints": [ - { - "attributes": [{"name": "trhvzyvaqy", "value": "evpkgsskyavybxwwssm"}], - "branchId": "rzsyrhpfbydxtfkpaa", - "endpointType": "read_only", - "entityName": "entity-name", - "projectId": "rtvdeeflqzlrpfzhjqhcsfbldw", - } - ], - "entityName": "entity-name", - "parentId": "entity-id", - "projectId": "oik", - "roleName": "qrrairsupyosxnqotdwhbpc", - "roles": [ - { - "attributes": [{"name": "trhvzyvaqy", "value": "evpkgsskyavybxwwssm"}], - "branchId": "wxbojkmdgaggkfiwqfakdkbyztm", - "entityName": "entity-name", - "isSuperUser": True, - "permissions": ["myucqecpjriewzohxvadgkhiudnyx"], - } - ], - } - }, - ).result() - print(response) - - -# x-ms-original-file: 2025-03-01/Branches_Update_MaximumSet_Gen.json -if __name__ == "__main__": - main() diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/computes_create_or_update_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/computes_create_or_update_maximum_set_gen.py deleted file mode 100644 index 2829f960777b..000000000000 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/computes_create_or_update_maximum_set_gen.py +++ /dev/null @@ -1,55 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.neonpostgres import NeonPostgresMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-neonpostgres -# USAGE - python computes_create_or_update_maximum_set_gen.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 = NeonPostgresMgmtClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.computes.begin_create_or_update( - resource_group_name="rgneon", - organization_name="test-org", - project_name="entity-name", - branch_name="entity-name", - compute_name="entity-name", - resource={ - "properties": { - "attributes": [{"name": "trhvzyvaqy", "value": "evpkgsskyavybxwwssm"}], - "cpuCores": 29, - "entityName": "entity-name", - "memory": 2, - "region": "mcfyojzptdliawyuxyxzqxif", - "status": "upwdpznysuwt", - } - }, - ).result() - print(response) - - -# x-ms-original-file: 2025-03-01/Computes_CreateOrUpdate_MaximumSet_Gen.json -if __name__ == "__main__": - main() diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/computes_get_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/computes_get_maximum_set_gen.py deleted file mode 100644 index c50ded1e4236..000000000000 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/computes_get_maximum_set_gen.py +++ /dev/null @@ -1,45 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.neonpostgres import NeonPostgresMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-neonpostgres -# USAGE - python computes_get_maximum_set_gen.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 = NeonPostgresMgmtClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.computes.get( - resource_group_name="rgneon", - organization_name="test-org", - project_name="entity-name", - branch_name="entity-name", - compute_name="entity-name", - ) - print(response) - - -# x-ms-original-file: 2025-03-01/Computes_Get_MaximumSet_Gen.json -if __name__ == "__main__": - main() diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/computes_list_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/computes_list_maximum_set_gen.py index fedfff098c50..6df8775f6f1c 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/computes_list_maximum_set_gen.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/computes_list_maximum_set_gen.py @@ -32,9 +32,9 @@ def main(): response = client.computes.list( resource_group_name="rgneon", - organization_name="test-org", - project_name="entity-name", - branch_name="entity-name", + organization_name="contoso-org", + project_name="sample-resource", + branch_name="sample-resource", ) for item in response: print(item) diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/computes_update_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/computes_update_maximum_set_gen.py deleted file mode 100644 index 7b961bbf39c0..000000000000 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/computes_update_maximum_set_gen.py +++ /dev/null @@ -1,55 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.neonpostgres import NeonPostgresMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-neonpostgres -# USAGE - python computes_update_maximum_set_gen.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 = NeonPostgresMgmtClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.computes.begin_update( - resource_group_name="rgneon", - organization_name="test-org", - project_name="entity-name", - branch_name="entity-name", - compute_name="entity-name", - properties={ - "properties": { - "attributes": [{"name": "trhvzyvaqy", "value": "evpkgsskyavybxwwssm"}], - "cpuCores": 29, - "entityName": "entity-name", - "memory": 2, - "region": "mcfyojzptdliawyuxyxzqxif", - "status": "upwdpznysuwt", - } - }, - ).result() - print(response) - - -# x-ms-original-file: 2025-03-01/Computes_Update_MaximumSet_Gen.json -if __name__ == "__main__": - main() diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/endpoints_create_or_update_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/endpoints_create_or_update_maximum_set_gen.py deleted file mode 100644 index ae51158bef95..000000000000 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/endpoints_create_or_update_maximum_set_gen.py +++ /dev/null @@ -1,54 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.neonpostgres import NeonPostgresMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-neonpostgres -# USAGE - python endpoints_create_or_update_maximum_set_gen.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 = NeonPostgresMgmtClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.endpoints.begin_create_or_update( - resource_group_name="rgneon", - organization_name="test-org", - project_name="entity-name", - branch_name="entity-name", - endpoint_name="entity-name", - resource={ - "properties": { - "attributes": [{"name": "trhvzyvaqy", "value": "evpkgsskyavybxwwssm"}], - "branchId": "rzsyrhpfbydxtfkpaa", - "endpointType": "read_only", - "entityName": "entity-name", - "projectId": "rtvdeeflqzlrpfzhjqhcsfbldw", - } - }, - ).result() - print(response) - - -# x-ms-original-file: 2025-03-01/Endpoints_CreateOrUpdate_MaximumSet_Gen.json -if __name__ == "__main__": - main() diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/endpoints_get_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/endpoints_get_maximum_set_gen.py deleted file mode 100644 index 83d2a39c3604..000000000000 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/endpoints_get_maximum_set_gen.py +++ /dev/null @@ -1,45 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.neonpostgres import NeonPostgresMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-neonpostgres -# USAGE - python endpoints_get_maximum_set_gen.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 = NeonPostgresMgmtClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.endpoints.get( - resource_group_name="rgneon", - organization_name="test-org", - project_name="entity-name", - branch_name="entity-name", - endpoint_name="entity-name", - ) - print(response) - - -# x-ms-original-file: 2025-03-01/Endpoints_Get_MaximumSet_Gen.json -if __name__ == "__main__": - main() diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/endpoints_list_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/endpoints_list_maximum_set_gen.py index beb5b5d810b5..cb338b576132 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/endpoints_list_maximum_set_gen.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/endpoints_list_maximum_set_gen.py @@ -32,9 +32,9 @@ def main(): response = client.endpoints.list( resource_group_name="rgneon", - organization_name="test-org", - project_name="entity-name", - branch_name="entity-name", + organization_name="contoso-org", + project_name="sample-resource", + branch_name="sample-resource", ) for item in response: print(item) diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/endpoints_update_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/endpoints_update_maximum_set_gen.py deleted file mode 100644 index e4a6f5d21be8..000000000000 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/endpoints_update_maximum_set_gen.py +++ /dev/null @@ -1,54 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.neonpostgres import NeonPostgresMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-neonpostgres -# USAGE - python endpoints_update_maximum_set_gen.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 = NeonPostgresMgmtClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.endpoints.begin_update( - resource_group_name="rgneon", - organization_name="test-org", - project_name="entity-name", - branch_name="entity-name", - endpoint_name="entity-name", - properties={ - "properties": { - "attributes": [{"name": "trhvzyvaqy", "value": "evpkgsskyavybxwwssm"}], - "branchId": "rzsyrhpfbydxtfkpaa", - "endpointType": "read_only", - "entityName": "entity-name", - "projectId": "rtvdeeflqzlrpfzhjqhcsfbldw", - } - }, - ).result() - print(response) - - -# x-ms-original-file: 2025-03-01/Endpoints_Update_MaximumSet_Gen.json -if __name__ == "__main__": - main() diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_databases_create_or_update_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_databases_create_or_update_maximum_set_gen.py deleted file mode 100644 index db5286fa1eb2..000000000000 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_databases_create_or_update_maximum_set_gen.py +++ /dev/null @@ -1,53 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.neonpostgres import NeonPostgresMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-neonpostgres -# USAGE - python neon_databases_create_or_update_maximum_set_gen.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 = NeonPostgresMgmtClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.neon_databases.begin_create_or_update( - resource_group_name="rgneon", - organization_name="test-org", - project_name="entity-name", - branch_name="entity-name", - neon_database_name="entity-name", - resource={ - "properties": { - "attributes": [{"name": "trhvzyvaqy", "value": "evpkgsskyavybxwwssm"}], - "branchId": "orfdwdmzvfvlnrgussvcvoek", - "entityName": "entity-name", - "ownerName": "odmbeg", - } - }, - ).result() - print(response) - - -# x-ms-original-file: 2025-03-01/NeonDatabases_CreateOrUpdate_MaximumSet_Gen.json -if __name__ == "__main__": - main() diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_databases_delete_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_databases_delete_maximum_set_gen.py deleted file mode 100644 index ccaacdf27c03..000000000000 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_databases_delete_maximum_set_gen.py +++ /dev/null @@ -1,44 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.neonpostgres import NeonPostgresMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-neonpostgres -# USAGE - python neon_databases_delete_maximum_set_gen.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 = NeonPostgresMgmtClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - client.neon_databases.delete( - resource_group_name="rgneon", - organization_name="test-org", - project_name="entity-name", - branch_name="entity-name", - neon_database_name="entity-name", - ) - - -# x-ms-original-file: 2025-03-01/NeonDatabases_Delete_MaximumSet_Gen.json -if __name__ == "__main__": - main() diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_databases_get_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_databases_get_maximum_set_gen.py deleted file mode 100644 index 6624eafd84c7..000000000000 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_databases_get_maximum_set_gen.py +++ /dev/null @@ -1,45 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.neonpostgres import NeonPostgresMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-neonpostgres -# USAGE - python neon_databases_get_maximum_set_gen.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 = NeonPostgresMgmtClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.neon_databases.get( - resource_group_name="rgneon", - organization_name="test-org", - project_name="entity-name", - branch_name="entity-name", - neon_database_name="entity-name", - ) - print(response) - - -# x-ms-original-file: 2025-03-01/NeonDatabases_Get_MaximumSet_Gen.json -if __name__ == "__main__": - main() diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_databases_list_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_databases_list_maximum_set_gen.py index c0d12be768a9..07caae10bf4f 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_databases_list_maximum_set_gen.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_databases_list_maximum_set_gen.py @@ -32,9 +32,9 @@ def main(): response = client.neon_databases.list( resource_group_name="rgneon", - organization_name="test-org", - project_name="entity-name", - branch_name="entity-name", + organization_name="contoso-org", + project_name="sample-resource", + branch_name="sample-resource", ) for item in response: print(item) diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_databases_update_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_databases_update_maximum_set_gen.py deleted file mode 100644 index d49b096e3f77..000000000000 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_databases_update_maximum_set_gen.py +++ /dev/null @@ -1,53 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.neonpostgres import NeonPostgresMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-neonpostgres -# USAGE - python neon_databases_update_maximum_set_gen.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 = NeonPostgresMgmtClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.neon_databases.begin_update( - resource_group_name="rgneon", - organization_name="test-org", - project_name="entity-name", - branch_name="entity-name", - neon_database_name="entity-name", - properties={ - "properties": { - "attributes": [{"name": "trhvzyvaqy", "value": "evpkgsskyavybxwwssm"}], - "branchId": "orfdwdmzvfvlnrgussvcvoek", - "entityName": "entity-name", - "ownerName": "odmbeg", - } - }, - ).result() - print(response) - - -# x-ms-original-file: 2025-03-01/NeonDatabases_Update_MaximumSet_Gen.json -if __name__ == "__main__": - main() diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_roles_create_or_update_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_roles_create_or_update_maximum_set_gen.py deleted file mode 100644 index 0e5c4a9fc595..000000000000 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_roles_create_or_update_maximum_set_gen.py +++ /dev/null @@ -1,54 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.neonpostgres import NeonPostgresMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-neonpostgres -# USAGE - python neon_roles_create_or_update_maximum_set_gen.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 = NeonPostgresMgmtClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.neon_roles.begin_create_or_update( - resource_group_name="rgneon", - organization_name="test-org", - project_name="entity-name", - branch_name="entity-name", - neon_role_name="entity-name", - resource={ - "properties": { - "attributes": [{"name": "trhvzyvaqy", "value": "evpkgsskyavybxwwssm"}], - "branchId": "wxbojkmdgaggkfiwqfakdkbyztm", - "entityName": "entity-name", - "isSuperUser": True, - "permissions": ["myucqecpjriewzohxvadgkhiudnyx"], - } - }, - ).result() - print(response) - - -# x-ms-original-file: 2025-03-01/NeonRoles_CreateOrUpdate_MaximumSet_Gen.json -if __name__ == "__main__": - main() diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_roles_delete_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_roles_delete_maximum_set_gen.py deleted file mode 100644 index ad9481c8c243..000000000000 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_roles_delete_maximum_set_gen.py +++ /dev/null @@ -1,44 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.neonpostgres import NeonPostgresMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-neonpostgres -# USAGE - python neon_roles_delete_maximum_set_gen.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 = NeonPostgresMgmtClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - client.neon_roles.delete( - resource_group_name="rgneon", - organization_name="test-org", - project_name="entity-name", - branch_name="entity-name", - neon_role_name="entity-name", - ) - - -# x-ms-original-file: 2025-03-01/NeonRoles_Delete_MaximumSet_Gen.json -if __name__ == "__main__": - main() diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_roles_get_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_roles_get_maximum_set_gen.py deleted file mode 100644 index a45b7b24d2b2..000000000000 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_roles_get_maximum_set_gen.py +++ /dev/null @@ -1,45 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.neonpostgres import NeonPostgresMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-neonpostgres -# USAGE - python neon_roles_get_maximum_set_gen.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 = NeonPostgresMgmtClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.neon_roles.get( - resource_group_name="rgneon", - organization_name="test-org", - project_name="entity-name", - branch_name="entity-name", - neon_role_name="entity-name", - ) - print(response) - - -# x-ms-original-file: 2025-03-01/NeonRoles_Get_MaximumSet_Gen.json -if __name__ == "__main__": - main() diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_roles_list_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_roles_list_maximum_set_gen.py index 758d8e3f2fbf..001ccc2d7cf2 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_roles_list_maximum_set_gen.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_roles_list_maximum_set_gen.py @@ -32,9 +32,9 @@ def main(): response = client.neon_roles.list( resource_group_name="rgneon", - organization_name="test-org", - project_name="entity-name", - branch_name="entity-name", + organization_name="contoso-org", + project_name="sample-resource", + branch_name="sample-resource", ) for item in response: print(item) diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_roles_update_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_roles_update_maximum_set_gen.py deleted file mode 100644 index 44b91e874bd8..000000000000 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_roles_update_maximum_set_gen.py +++ /dev/null @@ -1,54 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.neonpostgres import NeonPostgresMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-neonpostgres -# USAGE - python neon_roles_update_maximum_set_gen.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 = NeonPostgresMgmtClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.neon_roles.begin_update( - resource_group_name="rgneon", - organization_name="test-org", - project_name="entity-name", - branch_name="entity-name", - neon_role_name="entity-name", - properties={ - "properties": { - "attributes": [{"name": "trhvzyvaqy", "value": "evpkgsskyavybxwwssm"}], - "branchId": "wxbojkmdgaggkfiwqfakdkbyztm", - "entityName": "entity-name", - "isSuperUser": True, - "permissions": ["myucqecpjriewzohxvadgkhiudnyx"], - } - }, - ).result() - print(response) - - -# x-ms-original-file: 2025-03-01/NeonRoles_Update_MaximumSet_Gen.json -if __name__ == "__main__": - main() diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_create_or_update_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_create_or_update_maximum_set_gen.py index e8af1709f1bb..12fac60e1519 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_create_or_update_maximum_set_gen.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_create_or_update_maximum_set_gen.py @@ -32,7 +32,7 @@ def main(): response = client.organizations.begin_create_or_update( resource_group_name="rgneon", - organization_name="test-org", + organization_name="contoso-org", resource={ "location": "kcdph", "properties": { @@ -143,7 +143,7 @@ def main(): "upn": "mixcikvxlnhkfugetqlngz", }, }, - "tags": {"key8832": "rvukepuxkykdtqjtwk"}, + "tags": {}, }, ).result() print(response) diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_delete_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_delete_maximum_set_gen.py index 5c0595324dae..97243f809655 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_delete_maximum_set_gen.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_delete_maximum_set_gen.py @@ -32,7 +32,7 @@ def main(): client.organizations.begin_delete( resource_group_name="rgneon", - organization_name="test-org", + organization_name="contoso-org", ).result() diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_get_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_get_maximum_set_gen.py index 99a22e1a0832..9d8ef35bc5fd 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_get_maximum_set_gen.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_get_maximum_set_gen.py @@ -32,7 +32,7 @@ def main(): response = client.organizations.get( resource_group_name="rgneon", - organization_name="test-org", + organization_name="contoso-org", ) print(response) diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/computes_delete_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_list_by_resource_group_minimum_set_gen.py similarity index 81% rename from sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/computes_delete_maximum_set_gen.py rename to sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_list_by_resource_group_minimum_set_gen.py index e6bc1653c53e..7d089b1d9271 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/computes_delete_maximum_set_gen.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_list_by_resource_group_minimum_set_gen.py @@ -15,7 +15,7 @@ pip install azure-identity pip install azure-mgmt-neonpostgres # USAGE - python computes_delete_maximum_set_gen.py + python organizations_list_by_resource_group_minimum_set_gen.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, @@ -30,15 +30,13 @@ def main(): subscription_id="SUBSCRIPTION_ID", ) - client.computes.delete( + response = client.organizations.list_by_resource_group( resource_group_name="rgneon", - organization_name="test-org", - project_name="entity-name", - branch_name="entity-name", - compute_name="entity-name", ) + for item in response: + print(item) -# x-ms-original-file: 2025-03-01/Computes_Delete_MaximumSet_Gen.json +# x-ms-original-file: 2025-03-01/Organizations_ListByResourceGroup_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/endpoints_delete_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_list_by_subscription_minimum_set_gen.py similarity index 78% rename from sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/endpoints_delete_maximum_set_gen.py rename to sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_list_by_subscription_minimum_set_gen.py index 45ecff88f4be..3ab06d1bd49e 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/endpoints_delete_maximum_set_gen.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_list_by_subscription_minimum_set_gen.py @@ -15,7 +15,7 @@ pip install azure-identity pip install azure-mgmt-neonpostgres # USAGE - python endpoints_delete_maximum_set_gen.py + python organizations_list_by_subscription_minimum_set_gen.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, @@ -30,15 +30,11 @@ def main(): subscription_id="SUBSCRIPTION_ID", ) - client.endpoints.delete( - resource_group_name="rgneon", - organization_name="test-org", - project_name="entity-name", - branch_name="entity-name", - endpoint_name="entity-name", - ) + response = client.organizations.list_by_subscription() + for item in response: + print(item) -# x-ms-original-file: 2025-03-01/Endpoints_Delete_MaximumSet_Gen.json +# x-ms-original-file: 2025-03-01/Organizations_ListBySubscription_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_update_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_update_maximum_set_gen.py index 1790d80814d0..89b8980c9a68 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_update_maximum_set_gen.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_update_maximum_set_gen.py @@ -32,7 +32,7 @@ def main(): response = client.organizations.begin_update( resource_group_name="rgneon", - organization_name="test-org", + organization_name="contoso-org", properties={ "properties": { "companyDetails": { @@ -43,6 +43,18 @@ def main(): "numberOfEmployees": 12, "officeAddress": "icirtoqmmozijk", }, + "marketplaceDetails": { + "offerDetails": { + "offerId": "bunyeeupoedueofwrzej", + "planId": "nlbfiwtslenfwek", + "planName": "ljbmgpkfqklaufacbpml", + "publisherId": "hporaxnopmolttlnkbarw", + "termId": "aedlchikwqckuploswthvshe", + "termUnit": "qbcq", + }, + "subscriptionId": "yxmkfivp", + "subscriptionStatus": "PendingFulfillmentStart", + }, "partnerOrganizationProperties": { "organizationId": "fynmpcbivqkwqdfhrmsyusjd", "organizationName": "entity-name", @@ -130,7 +142,7 @@ def main(): "upn": "mixcikvxlnhkfugetqlngz", }, }, - "tags": {"key609": "qyosjypklxtiamqebd"}, + "tags": {}, }, ).result() print(response) diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/projects_create_or_update_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/projects_create_or_update_maximum_set_gen.py index ae3783c6ce8d..fd43b35cfb3d 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/projects_create_or_update_maximum_set_gen.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/projects_create_or_update_maximum_set_gen.py @@ -32,8 +32,8 @@ def main(): response = client.projects.begin_create_or_update( resource_group_name="rgneon", - organization_name="test-org", - project_name="entity-name", + organization_name="contoso-org", + project_name="sample-resource", resource={ "properties": { "attributes": [{"name": "trhvzyvaqy", "value": "evpkgsskyavybxwwssm"}], diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/projects_delete_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/projects_delete_maximum_set_gen.py index fe27a447f453..0b0878076854 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/projects_delete_maximum_set_gen.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/projects_delete_maximum_set_gen.py @@ -32,8 +32,8 @@ def main(): client.projects.delete( resource_group_name="rgneon", - organization_name="test-org", - project_name="entity-name", + organization_name="contoso-org", + project_name="sample-resource", ) diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/projects_get_connection_uri_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/projects_get_connection_uri_maximum_set_gen.py index 3b19816b5b52..037bcaa8c06c 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/projects_get_connection_uri_maximum_set_gen.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/projects_get_connection_uri_maximum_set_gen.py @@ -32,8 +32,8 @@ def main(): response = client.projects.get_connection_uri( resource_group_name="rgneon", - organization_name="test-org", - project_name="entity-name", + organization_name="contoso-org", + project_name="sample-resource", connection_uri_parameters={ "branchId": "iimmlbqv", "databaseName": "xc", diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/projects_get_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/projects_get_maximum_set_gen.py index 3c3d3312456d..b31397c544b4 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/projects_get_maximum_set_gen.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/projects_get_maximum_set_gen.py @@ -32,8 +32,8 @@ def main(): response = client.projects.get( resource_group_name="rgneon", - organization_name="test-org", - project_name="entity-name", + organization_name="contoso-org", + project_name="sample-resource", ) print(response) diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/projects_list_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/projects_list_maximum_set_gen.py index eb79c2e276e4..3d37360f7536 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/projects_list_maximum_set_gen.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/projects_list_maximum_set_gen.py @@ -32,7 +32,7 @@ def main(): response = client.projects.list( resource_group_name="rgneon", - organization_name="test-org", + organization_name="contoso-org", ) for item in response: print(item) diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/projects_update_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/projects_update_maximum_set_gen.py deleted file mode 100644 index 2baae801d1b9..000000000000 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/projects_update_maximum_set_gen.py +++ /dev/null @@ -1,114 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.neonpostgres import NeonPostgresMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-neonpostgres -# USAGE - python projects_update_maximum_set_gen.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 = NeonPostgresMgmtClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.projects.begin_update( - resource_group_name="rgneon", - organization_name="test-org", - project_name="test-project", - properties={ - "properties": { - "attributes": [{"name": "trhvzyvaqy", "value": "evpkgsskyavybxwwssm"}], - "branch": { - "attributes": [{"name": "trhvzyvaqy", "value": "evpkgsskyavybxwwssm"}], - "databaseName": "duhxebzhd", - "databases": [ - { - "attributes": [{"name": "trhvzyvaqy", "value": "evpkgsskyavybxwwssm"}], - "branchId": "orfdwdmzvfvlnrgussvcvoek", - "entityName": "entity-name", - "ownerName": "odmbeg", - } - ], - "endpoints": [ - { - "attributes": [{"name": "trhvzyvaqy", "value": "evpkgsskyavybxwwssm"}], - "branchId": "rzsyrhpfbydxtfkpaa", - "endpointType": "read_only", - "entityName": "entity-name", - "projectId": "rtvdeeflqzlrpfzhjqhcsfbldw", - } - ], - "entityName": "entity-name", - "parentId": "entity-id", - "projectId": "oik", - "roleName": "qrrairsupyosxnqotdwhbpc", - "roles": [ - { - "attributes": [{"name": "trhvzyvaqy", "value": "evpkgsskyavybxwwssm"}], - "branchId": "wxbojkmdgaggkfiwqfakdkbyztm", - "entityName": "entity-name", - "isSuperUser": True, - "permissions": ["myucqecpjriewzohxvadgkhiudnyx"], - } - ], - }, - "databases": [ - { - "attributes": [{"name": "trhvzyvaqy", "value": "evpkgsskyavybxwwssm"}], - "branchId": "orfdwdmzvfvlnrgussvcvoek", - "entityName": "entity-name", - "ownerName": "odmbeg", - } - ], - "defaultEndpointSettings": {"autoscalingLimitMaxCu": 4, "autoscalingLimitMinCu": 8}, - "endpoints": [ - { - "attributes": [{"name": "trhvzyvaqy", "value": "evpkgsskyavybxwwssm"}], - "branchId": "rzsyrhpfbydxtfkpaa", - "endpointType": "read_only", - "entityName": "entity-name", - "projectId": "rtvdeeflqzlrpfzhjqhcsfbldw", - } - ], - "entityName": "entity-name", - "historyRetention": 16, - "pgVersion": 16, - "regionId": "vxvmjwuttpiakirzdf", - "roles": [ - { - "attributes": [{"name": "trhvzyvaqy", "value": "evpkgsskyavybxwwssm"}], - "branchId": "wxbojkmdgaggkfiwqfakdkbyztm", - "entityName": "entity-name", - "isSuperUser": True, - "permissions": ["myucqecpjriewzohxvadgkhiudnyx"], - } - ], - "storage": 23, - } - }, - ).result() - print(response) - - -# x-ms-original-file: 2025-03-01/Projects_Update_MaximumSet_Gen.json -if __name__ == "__main__": - main() diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_branches_operations.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_branches_operations.py index 86a49299c170..e92ee1783047 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_branches_operations.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_branches_operations.py @@ -103,78 +103,6 @@ def test_branches_begin_create_or_update(self, resource_group): # please add some check logic here by yourself # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_branches_begin_update(self, resource_group): - response = self.client.branches.begin_update( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - properties={ - "id": "str", - "name": "str", - "properties": { - "attributes": [{"name": "str", "value": "str"}], - "createdAt": "str", - "databaseName": "str", - "databases": [ - { - "attributes": [{"name": "str", "value": "str"}], - "branchId": "str", - "createdAt": "str", - "entityId": "str", - "entityName": "str", - "ownerName": "str", - "provisioningState": "str", - } - ], - "endpoints": [ - { - "attributes": [{"name": "str", "value": "str"}], - "branchId": "str", - "createdAt": "str", - "endpointType": "str", - "entityId": "str", - "entityName": "str", - "projectId": "str", - "provisioningState": "str", - } - ], - "entityId": "str", - "entityName": "str", - "parentId": "str", - "projectId": "str", - "provisioningState": "str", - "roleName": "str", - "roles": [ - { - "attributes": [{"name": "str", "value": "str"}], - "branchId": "str", - "createdAt": "str", - "entityId": "str", - "entityName": "str", - "isSuperUser": bool, - "permissions": ["str"], - "provisioningState": "str", - } - ], - }, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ).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_branches_delete(self, resource_group): diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_branches_operations_async.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_branches_operations_async.py index daad42cfedfc..ea1f1dc144c1 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_branches_operations_async.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_branches_operations_async.py @@ -106,80 +106,6 @@ async def test_branches_begin_create_or_update(self, resource_group): # please add some check logic here by yourself # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_branches_begin_update(self, resource_group): - response = await ( - await self.client.branches.begin_update( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - properties={ - "id": "str", - "name": "str", - "properties": { - "attributes": [{"name": "str", "value": "str"}], - "createdAt": "str", - "databaseName": "str", - "databases": [ - { - "attributes": [{"name": "str", "value": "str"}], - "branchId": "str", - "createdAt": "str", - "entityId": "str", - "entityName": "str", - "ownerName": "str", - "provisioningState": "str", - } - ], - "endpoints": [ - { - "attributes": [{"name": "str", "value": "str"}], - "branchId": "str", - "createdAt": "str", - "endpointType": "str", - "entityId": "str", - "entityName": "str", - "projectId": "str", - "provisioningState": "str", - } - ], - "entityId": "str", - "entityName": "str", - "parentId": "str", - "projectId": "str", - "provisioningState": "str", - "roleName": "str", - "roles": [ - { - "attributes": [{"name": "str", "value": "str"}], - "branchId": "str", - "createdAt": "str", - "entityId": "str", - "entityName": "str", - "isSuperUser": bool, - "permissions": ["str"], - "provisioningState": "str", - } - ], - }, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ) - ).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_branches_delete(self, resource_group): diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_computes_operations.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_computes_operations.py index f56beceb8f73..51fb96a51385 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_computes_operations.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_computes_operations.py @@ -18,110 +18,6 @@ class TestNeonPostgresMgmtComputesOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(NeonPostgresMgmtClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_computes_get(self, resource_group): - response = self.client.computes.get( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - compute_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_computes_begin_create_or_update(self, resource_group): - response = self.client.computes.begin_create_or_update( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - compute_name="str", - resource={ - "id": "str", - "name": "str", - "properties": { - "attributes": [{"name": "str", "value": "str"}], - "cpuCores": 0, - "createdAt": "str", - "entityId": "str", - "entityName": "str", - "memory": 0, - "provisioningState": "str", - "region": "str", - "status": "str", - }, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ).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_computes_begin_update(self, resource_group): - response = self.client.computes.begin_update( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - compute_name="str", - properties={ - "id": "str", - "name": "str", - "properties": { - "attributes": [{"name": "str", "value": "str"}], - "cpuCores": 0, - "createdAt": "str", - "entityId": "str", - "entityName": "str", - "memory": 0, - "provisioningState": "str", - "region": "str", - "status": "str", - }, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ).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_computes_delete(self, resource_group): - response = self.client.computes.delete( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - compute_name="str", - ) - - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_computes_list(self, resource_group): diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_computes_operations_async.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_computes_operations_async.py index 92ad9469c74b..44d506bcf702 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_computes_operations_async.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_computes_operations_async.py @@ -19,114 +19,6 @@ class TestNeonPostgresMgmtComputesOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(NeonPostgresMgmtClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_computes_get(self, resource_group): - response = await self.client.computes.get( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - compute_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_computes_begin_create_or_update(self, resource_group): - response = await ( - await self.client.computes.begin_create_or_update( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - compute_name="str", - resource={ - "id": "str", - "name": "str", - "properties": { - "attributes": [{"name": "str", "value": "str"}], - "cpuCores": 0, - "createdAt": "str", - "entityId": "str", - "entityName": "str", - "memory": 0, - "provisioningState": "str", - "region": "str", - "status": "str", - }, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ) - ).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_computes_begin_update(self, resource_group): - response = await ( - await self.client.computes.begin_update( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - compute_name="str", - properties={ - "id": "str", - "name": "str", - "properties": { - "attributes": [{"name": "str", "value": "str"}], - "cpuCores": 0, - "createdAt": "str", - "entityId": "str", - "entityName": "str", - "memory": 0, - "provisioningState": "str", - "region": "str", - "status": "str", - }, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ) - ).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_computes_delete(self, resource_group): - response = await self.client.computes.delete( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - compute_name="str", - ) - - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_computes_list(self, resource_group): diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_endpoints_operations.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_endpoints_operations.py index 325430c3465d..37f247ab6638 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_endpoints_operations.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_endpoints_operations.py @@ -18,108 +18,6 @@ class TestNeonPostgresMgmtEndpointsOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(NeonPostgresMgmtClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_endpoints_get(self, resource_group): - response = self.client.endpoints.get( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - endpoint_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_endpoints_begin_create_or_update(self, resource_group): - response = self.client.endpoints.begin_create_or_update( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - endpoint_name="str", - resource={ - "id": "str", - "name": "str", - "properties": { - "attributes": [{"name": "str", "value": "str"}], - "branchId": "str", - "createdAt": "str", - "endpointType": "str", - "entityId": "str", - "entityName": "str", - "projectId": "str", - "provisioningState": "str", - }, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ).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_endpoints_begin_update(self, resource_group): - response = self.client.endpoints.begin_update( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - endpoint_name="str", - properties={ - "id": "str", - "name": "str", - "properties": { - "attributes": [{"name": "str", "value": "str"}], - "branchId": "str", - "createdAt": "str", - "endpointType": "str", - "entityId": "str", - "entityName": "str", - "projectId": "str", - "provisioningState": "str", - }, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ).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_endpoints_delete(self, resource_group): - response = self.client.endpoints.delete( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - endpoint_name="str", - ) - - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_endpoints_list(self, resource_group): diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_endpoints_operations_async.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_endpoints_operations_async.py index 34dc96ef044e..51dc80b1761b 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_endpoints_operations_async.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_endpoints_operations_async.py @@ -19,112 +19,6 @@ class TestNeonPostgresMgmtEndpointsOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(NeonPostgresMgmtClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_endpoints_get(self, resource_group): - response = await self.client.endpoints.get( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - endpoint_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_endpoints_begin_create_or_update(self, resource_group): - response = await ( - await self.client.endpoints.begin_create_or_update( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - endpoint_name="str", - resource={ - "id": "str", - "name": "str", - "properties": { - "attributes": [{"name": "str", "value": "str"}], - "branchId": "str", - "createdAt": "str", - "endpointType": "str", - "entityId": "str", - "entityName": "str", - "projectId": "str", - "provisioningState": "str", - }, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ) - ).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_endpoints_begin_update(self, resource_group): - response = await ( - await self.client.endpoints.begin_update( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - endpoint_name="str", - properties={ - "id": "str", - "name": "str", - "properties": { - "attributes": [{"name": "str", "value": "str"}], - "branchId": "str", - "createdAt": "str", - "endpointType": "str", - "entityId": "str", - "entityName": "str", - "projectId": "str", - "provisioningState": "str", - }, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ) - ).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_endpoints_delete(self, resource_group): - response = await self.client.endpoints.delete( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - endpoint_name="str", - ) - - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_endpoints_list(self, resource_group): diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_neon_databases_operations.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_neon_databases_operations.py index 717326a88fac..d092f7ed7bce 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_neon_databases_operations.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_neon_databases_operations.py @@ -18,106 +18,6 @@ class TestNeonPostgresMgmtNeonDatabasesOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(NeonPostgresMgmtClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_neon_databases_get(self, resource_group): - response = self.client.neon_databases.get( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - neon_database_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_neon_databases_begin_create_or_update(self, resource_group): - response = self.client.neon_databases.begin_create_or_update( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - neon_database_name="str", - resource={ - "id": "str", - "name": "str", - "properties": { - "attributes": [{"name": "str", "value": "str"}], - "branchId": "str", - "createdAt": "str", - "entityId": "str", - "entityName": "str", - "ownerName": "str", - "provisioningState": "str", - }, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ).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_neon_databases_begin_update(self, resource_group): - response = self.client.neon_databases.begin_update( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - neon_database_name="str", - properties={ - "id": "str", - "name": "str", - "properties": { - "attributes": [{"name": "str", "value": "str"}], - "branchId": "str", - "createdAt": "str", - "entityId": "str", - "entityName": "str", - "ownerName": "str", - "provisioningState": "str", - }, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ).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_neon_databases_delete(self, resource_group): - response = self.client.neon_databases.delete( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - neon_database_name="str", - ) - - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_neon_databases_list(self, resource_group): diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_neon_databases_operations_async.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_neon_databases_operations_async.py index 0c2662346220..171a073fe35f 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_neon_databases_operations_async.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_neon_databases_operations_async.py @@ -19,110 +19,6 @@ class TestNeonPostgresMgmtNeonDatabasesOperationsAsync(AzureMgmtRecordedTestCase def setup_method(self, method): self.client = self.create_mgmt_client(NeonPostgresMgmtClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_neon_databases_get(self, resource_group): - response = await self.client.neon_databases.get( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - neon_database_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_neon_databases_begin_create_or_update(self, resource_group): - response = await ( - await self.client.neon_databases.begin_create_or_update( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - neon_database_name="str", - resource={ - "id": "str", - "name": "str", - "properties": { - "attributes": [{"name": "str", "value": "str"}], - "branchId": "str", - "createdAt": "str", - "entityId": "str", - "entityName": "str", - "ownerName": "str", - "provisioningState": "str", - }, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ) - ).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_neon_databases_begin_update(self, resource_group): - response = await ( - await self.client.neon_databases.begin_update( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - neon_database_name="str", - properties={ - "id": "str", - "name": "str", - "properties": { - "attributes": [{"name": "str", "value": "str"}], - "branchId": "str", - "createdAt": "str", - "entityId": "str", - "entityName": "str", - "ownerName": "str", - "provisioningState": "str", - }, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ) - ).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_neon_databases_delete(self, resource_group): - response = await self.client.neon_databases.delete( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - neon_database_name="str", - ) - - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_neon_databases_list(self, resource_group): diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_neon_roles_operations.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_neon_roles_operations.py index 72b953407189..c9d7f44aa8bc 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_neon_roles_operations.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_neon_roles_operations.py @@ -18,108 +18,6 @@ class TestNeonPostgresMgmtNeonRolesOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(NeonPostgresMgmtClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_neon_roles_get(self, resource_group): - response = self.client.neon_roles.get( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - neon_role_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_neon_roles_begin_create_or_update(self, resource_group): - response = self.client.neon_roles.begin_create_or_update( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - neon_role_name="str", - resource={ - "id": "str", - "name": "str", - "properties": { - "attributes": [{"name": "str", "value": "str"}], - "branchId": "str", - "createdAt": "str", - "entityId": "str", - "entityName": "str", - "isSuperUser": bool, - "permissions": ["str"], - "provisioningState": "str", - }, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ).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_neon_roles_begin_update(self, resource_group): - response = self.client.neon_roles.begin_update( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - neon_role_name="str", - properties={ - "id": "str", - "name": "str", - "properties": { - "attributes": [{"name": "str", "value": "str"}], - "branchId": "str", - "createdAt": "str", - "entityId": "str", - "entityName": "str", - "isSuperUser": bool, - "permissions": ["str"], - "provisioningState": "str", - }, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ).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_neon_roles_delete(self, resource_group): - response = self.client.neon_roles.delete( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - neon_role_name="str", - ) - - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_neon_roles_list(self, resource_group): diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_neon_roles_operations_async.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_neon_roles_operations_async.py index df4b345cb271..1790a8c3f7bd 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_neon_roles_operations_async.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_neon_roles_operations_async.py @@ -19,112 +19,6 @@ class TestNeonPostgresMgmtNeonRolesOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(NeonPostgresMgmtClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_neon_roles_get(self, resource_group): - response = await self.client.neon_roles.get( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - neon_role_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_neon_roles_begin_create_or_update(self, resource_group): - response = await ( - await self.client.neon_roles.begin_create_or_update( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - neon_role_name="str", - resource={ - "id": "str", - "name": "str", - "properties": { - "attributes": [{"name": "str", "value": "str"}], - "branchId": "str", - "createdAt": "str", - "entityId": "str", - "entityName": "str", - "isSuperUser": bool, - "permissions": ["str"], - "provisioningState": "str", - }, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ) - ).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_neon_roles_begin_update(self, resource_group): - response = await ( - await self.client.neon_roles.begin_update( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - neon_role_name="str", - properties={ - "id": "str", - "name": "str", - "properties": { - "attributes": [{"name": "str", "value": "str"}], - "branchId": "str", - "createdAt": "str", - "entityId": "str", - "entityName": "str", - "isSuperUser": bool, - "permissions": ["str"], - "provisioningState": "str", - }, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ) - ).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_neon_roles_delete(self, resource_group): - response = await self.client.neon_roles.delete( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - branch_name="str", - neon_role_name="str", - ) - - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_neon_roles_list(self, resource_group): diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_projects_operations.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_projects_operations.py index 91aff0fd5c98..4f2ac097efea 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_projects_operations.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_projects_operations.py @@ -148,124 +148,6 @@ def test_projects_begin_create_or_update(self, resource_group): # please add some check logic here by yourself # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_projects_begin_update(self, resource_group): - response = self.client.projects.begin_update( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - properties={ - "id": "str", - "name": "str", - "properties": { - "attributes": [{"name": "str", "value": "str"}], - "branch": { - "attributes": [{"name": "str", "value": "str"}], - "createdAt": "str", - "databaseName": "str", - "databases": [ - { - "attributes": [{"name": "str", "value": "str"}], - "branchId": "str", - "createdAt": "str", - "entityId": "str", - "entityName": "str", - "ownerName": "str", - "provisioningState": "str", - } - ], - "endpoints": [ - { - "attributes": [{"name": "str", "value": "str"}], - "branchId": "str", - "createdAt": "str", - "endpointType": "str", - "entityId": "str", - "entityName": "str", - "projectId": "str", - "provisioningState": "str", - } - ], - "entityId": "str", - "entityName": "str", - "parentId": "str", - "projectId": "str", - "provisioningState": "str", - "roleName": "str", - "roles": [ - { - "attributes": [{"name": "str", "value": "str"}], - "branchId": "str", - "createdAt": "str", - "entityId": "str", - "entityName": "str", - "isSuperUser": bool, - "permissions": ["str"], - "provisioningState": "str", - } - ], - }, - "createdAt": "str", - "databases": [ - { - "attributes": [{"name": "str", "value": "str"}], - "branchId": "str", - "createdAt": "str", - "entityId": "str", - "entityName": "str", - "ownerName": "str", - "provisioningState": "str", - } - ], - "defaultEndpointSettings": {"autoscalingLimitMaxCu": 0.0, "autoscalingLimitMinCu": 0.0}, - "endpoints": [ - { - "attributes": [{"name": "str", "value": "str"}], - "branchId": "str", - "createdAt": "str", - "endpointType": "str", - "entityId": "str", - "entityName": "str", - "projectId": "str", - "provisioningState": "str", - } - ], - "entityId": "str", - "entityName": "str", - "historyRetention": 0, - "pgVersion": 0, - "provisioningState": "str", - "regionId": "str", - "roles": [ - { - "attributes": [{"name": "str", "value": "str"}], - "branchId": "str", - "createdAt": "str", - "entityId": "str", - "entityName": "str", - "isSuperUser": bool, - "permissions": ["str"], - "provisioningState": "str", - } - ], - "storage": 0, - }, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ).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_projects_delete(self, resource_group): diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_projects_operations_async.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_projects_operations_async.py index c161c37f92c9..fca93fce3286 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_projects_operations_async.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_projects_operations_async.py @@ -151,126 +151,6 @@ async def test_projects_begin_create_or_update(self, resource_group): # please add some check logic here by yourself # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_projects_begin_update(self, resource_group): - response = await ( - await self.client.projects.begin_update( - resource_group_name=resource_group.name, - organization_name="str", - project_name="str", - properties={ - "id": "str", - "name": "str", - "properties": { - "attributes": [{"name": "str", "value": "str"}], - "branch": { - "attributes": [{"name": "str", "value": "str"}], - "createdAt": "str", - "databaseName": "str", - "databases": [ - { - "attributes": [{"name": "str", "value": "str"}], - "branchId": "str", - "createdAt": "str", - "entityId": "str", - "entityName": "str", - "ownerName": "str", - "provisioningState": "str", - } - ], - "endpoints": [ - { - "attributes": [{"name": "str", "value": "str"}], - "branchId": "str", - "createdAt": "str", - "endpointType": "str", - "entityId": "str", - "entityName": "str", - "projectId": "str", - "provisioningState": "str", - } - ], - "entityId": "str", - "entityName": "str", - "parentId": "str", - "projectId": "str", - "provisioningState": "str", - "roleName": "str", - "roles": [ - { - "attributes": [{"name": "str", "value": "str"}], - "branchId": "str", - "createdAt": "str", - "entityId": "str", - "entityName": "str", - "isSuperUser": bool, - "permissions": ["str"], - "provisioningState": "str", - } - ], - }, - "createdAt": "str", - "databases": [ - { - "attributes": [{"name": "str", "value": "str"}], - "branchId": "str", - "createdAt": "str", - "entityId": "str", - "entityName": "str", - "ownerName": "str", - "provisioningState": "str", - } - ], - "defaultEndpointSettings": {"autoscalingLimitMaxCu": 0.0, "autoscalingLimitMinCu": 0.0}, - "endpoints": [ - { - "attributes": [{"name": "str", "value": "str"}], - "branchId": "str", - "createdAt": "str", - "endpointType": "str", - "entityId": "str", - "entityName": "str", - "projectId": "str", - "provisioningState": "str", - } - ], - "entityId": "str", - "entityName": "str", - "historyRetention": 0, - "pgVersion": 0, - "provisioningState": "str", - "regionId": "str", - "roles": [ - { - "attributes": [{"name": "str", "value": "str"}], - "branchId": "str", - "createdAt": "str", - "entityId": "str", - "entityName": "str", - "isSuperUser": bool, - "permissions": ["str"], - "provisioningState": "str", - } - ], - "storage": 0, - }, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ) - ).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_projects_delete(self, resource_group): diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/setup.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/setup.py index 090dc2220bcc..5652443359ad 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/setup.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/setup.py @@ -53,7 +53,6 @@ "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", @@ -77,7 +76,7 @@ "isodate>=0.6.1", "typing-extensions>=4.6.0", "azure-common>=1.1", - "azure-mgmt-core>=1.3.2", + "azure-mgmt-core>=1.5.0", ], - python_requires=">=3.8", + python_requires=">=3.9", ) diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/tsp-location.yaml b/sdk/neonpostgres/azure-mgmt-neonpostgres/tsp-location.yaml index 6e07630208ba..c745b44e3c35 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/tsp-location.yaml +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/liftrneon/Neon.Postgres.Management -commit: 917ba27f78348899fba4cafb37fcf018f1987a8e +commit: 9990ef08cbc4199a0ebea96403a23de493df11d7 repo: Azure/azure-rest-api-specs additionalDirectories: