diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/CHANGELOG.md b/sdk/neonpostgres/azure-mgmt-neonpostgres/CHANGELOG.md index 0fd51009a360..f66e3f0cb031 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/CHANGELOG.md +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/CHANGELOG.md @@ -1,5 +1,123 @@ # Release History +## 1.0.0 (2025-04-11) + +### Features Added + + - Client `NeonPostgresMgmtClient` added operation group `models` + - Client `NeonPostgresMgmtClient` added operation group `projects` + - Client `NeonPostgresMgmtClient` added operation group `branches` + - Client `NeonPostgresMgmtClient` added operation group `computes` + - Client `NeonPostgresMgmtClient` added operation group `neon_databases` + - Client `NeonPostgresMgmtClient` added operation group `neon_roles` + - Client `NeonPostgresMgmtClient` added operation group `endpoints` + - Model `OrganizationProperties` added property `project_properties` + - Added model `Attributes` + - Added model `Branch` + - Added model `BranchProperties` + - Added model `Compute` + - Added model `ComputeProperties` + - Added model `ConnectionUriProperties` + - Added model `DefaultEndpointSettings` + - Added model `Endpoint` + - Added model `EndpointProperties` + - Added enum `EndpointType` + - Added model `NeonDatabase` + - Added model `NeonDatabaseProperties` + - Added model `NeonRole` + - Added model `NeonRoleProperties` + - Added model `PgVersion` + - Added model `PgVersionsResult` + - Added model `Project` + - Added model `ProjectProperties` + - Added model `ProxyResource` + - Model `OrganizationsOperations` added method `get_postgres_versions` + - Added model `BranchesOperations` + - Added model `ComputesOperations` + - Added model `EndpointsOperations` + - Added model `ModelsOperations` + - Added model `NeonDatabasesOperations` + - Added model `NeonRolesOperations` + - Added model `ProjectsOperations` + - Method `Operation.__init__` has a new overload `def __init__(self: None, display: Optional[_models.OperationDisplay])` + - Method `OrganizationProperties.__init__` has a new overload `def __init__(self: None, marketplace_details: _models.MarketplaceDetails, user_details: _models.UserDetails, company_details: _models.CompanyDetails, partner_organization_properties: Optional[_models.PartnerOrganizationProperties], project_properties: Optional[_models.ProjectProperties])` + - Method `Attributes.__init__` has a new overload `def __init__(self: None, name: str, value: str)` + - Method `Attributes.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])` + - Method `Branch.__init__` has a new overload `def __init__(self: None, properties: Optional[_models.BranchProperties])` + - Method `Branch.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])` + - Method `BranchProperties.__init__` has a new overload `def __init__(self: None, entity_name: Optional[str], attributes: Optional[List[_models.Attributes]], project_id: Optional[str], parent_id: Optional[str], role_name: Optional[str], database_name: Optional[str], roles: Optional[List[_models.NeonRoleProperties]], databases: Optional[List[_models.NeonDatabaseProperties]], endpoints: Optional[List[_models.EndpointProperties]])` + - Method `BranchProperties.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])` + - Method `Compute.__init__` has a new overload `def __init__(self: None, properties: Optional[_models.ComputeProperties])` + - Method `Compute.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])` + - Method `ComputeProperties.__init__` has a new overload `def __init__(self: None, entity_name: Optional[str], attributes: Optional[List[_models.Attributes]], region: Optional[str], cpu_cores: Optional[int], memory: Optional[int], status: Optional[str])` + - Method `ComputeProperties.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])` + - Method `ConnectionUriProperties.__init__` has a new overload `def __init__(self: None, project_id: Optional[str], branch_id: Optional[str], database_name: Optional[str], role_name: Optional[str], endpoint_id: Optional[str], is_pooled: Optional[bool])` + - Method `ConnectionUriProperties.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])` + - Method `DefaultEndpointSettings.__init__` has a new overload `def __init__(self: None, autoscaling_limit_min_cu: float, autoscaling_limit_max_cu: float)` + - Method `DefaultEndpointSettings.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])` + - Method `Endpoint.__init__` has a new overload `def __init__(self: None, properties: Optional[_models.EndpointProperties])` + - Method `Endpoint.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])` + - Method `EndpointProperties.__init__` has a new overload `def __init__(self: None, entity_name: Optional[str], attributes: Optional[List[_models.Attributes]], project_id: Optional[str], branch_id: Optional[str], endpoint_type: Optional[Union[str, _models.EndpointType]])` + - Method `EndpointProperties.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])` + - Method `NeonDatabase.__init__` has a new overload `def __init__(self: None, properties: Optional[_models.NeonDatabaseProperties])` + - Method `NeonDatabase.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])` + - Method `NeonDatabaseProperties.__init__` has a new overload `def __init__(self: None, entity_name: Optional[str], attributes: Optional[List[_models.Attributes]], branch_id: Optional[str], owner_name: Optional[str])` + - Method `NeonDatabaseProperties.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])` + - Method `NeonRole.__init__` has a new overload `def __init__(self: None, properties: Optional[_models.NeonRoleProperties])` + - Method `NeonRole.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])` + - Method `NeonRoleProperties.__init__` has a new overload `def __init__(self: None, entity_name: Optional[str], attributes: Optional[List[_models.Attributes]], branch_id: Optional[str], permissions: Optional[List[str]], is_super_user: Optional[bool])` + - Method `NeonRoleProperties.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])` + - Method `PgVersion.__init__` has a new overload `def __init__(self: None, version: Optional[int])` + - Method `PgVersion.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])` + - Method `PgVersionsResult.__init__` has a new overload `def __init__(self: None, versions: List[_models.PgVersion])` + - Method `PgVersionsResult.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])` + - Method `Project.__init__` has a new overload `def __init__(self: None, properties: Optional[_models.ProjectProperties])` + - Method `Project.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])` + - Method `ProjectProperties.__init__` has a new overload `def __init__(self: None, entity_name: Optional[str], attributes: Optional[List[_models.Attributes]], region_id: Optional[str], storage: Optional[int], pg_version: Optional[int], history_retention: Optional[int], default_endpoint_settings: Optional[_models.DefaultEndpointSettings], branch: Optional[_models.BranchProperties], roles: Optional[List[_models.NeonRoleProperties]], databases: Optional[List[_models.NeonDatabaseProperties]], endpoints: Optional[List[_models.EndpointProperties]])` + - Method `ProjectProperties.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])` + - Method `OrganizationsOperations.get_postgres_versions` has a new overload `def get_postgres_versions(self: None, resource_group_name: str, parameters: Optional[PgVersion], content_type: str)` + - Method `OrganizationsOperations.get_postgres_versions` has a new overload `def get_postgres_versions(self: None, resource_group_name: str, parameters: Optional[JSON], content_type: str)` + - Method `OrganizationsOperations.get_postgres_versions` has a new overload `def get_postgres_versions(self: None, resource_group_name: str, parameters: Optional[IO[bytes]], content_type: str)` + - Method `BranchesOperations.begin_create_or_update` has a new overload `def begin_create_or_update(self: None, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, resource: Branch, content_type: str)` + - Method `BranchesOperations.begin_create_or_update` has a new overload `def begin_create_or_update(self: None, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, resource: JSON, content_type: str)` + - Method `BranchesOperations.begin_create_or_update` has a new overload `def begin_create_or_update(self: None, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, resource: IO[bytes], content_type: str)` + - Method `BranchesOperations.begin_update` has a new overload `def begin_update(self: None, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, properties: Branch, content_type: str)` + - Method `BranchesOperations.begin_update` has a new overload `def begin_update(self: None, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, properties: JSON, content_type: str)` + - Method `BranchesOperations.begin_update` has a new overload `def begin_update(self: None, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, properties: IO[bytes], content_type: str)` + - Method `ComputesOperations.begin_create_or_update` has a new overload `def begin_create_or_update(self: None, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, compute_name: str, resource: Compute, content_type: str)` + - Method `ComputesOperations.begin_create_or_update` has a new overload `def begin_create_or_update(self: None, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, compute_name: str, resource: JSON, content_type: str)` + - Method `ComputesOperations.begin_create_or_update` has a new overload `def begin_create_or_update(self: None, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, compute_name: str, resource: IO[bytes], content_type: str)` + - Method `ComputesOperations.begin_update` has a new overload `def begin_update(self: None, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, compute_name: str, properties: Compute, content_type: str)` + - Method `ComputesOperations.begin_update` has a new overload `def begin_update(self: None, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, compute_name: str, properties: JSON, content_type: str)` + - Method `ComputesOperations.begin_update` has a new overload `def begin_update(self: None, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, compute_name: str, properties: IO[bytes], content_type: str)` + - Method `EndpointsOperations.begin_create_or_update` has a new overload `def begin_create_or_update(self: None, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, endpoint_name: str, resource: Endpoint, content_type: str)` + - Method `EndpointsOperations.begin_create_or_update` has a new overload `def begin_create_or_update(self: None, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, endpoint_name: str, resource: JSON, content_type: str)` + - Method `EndpointsOperations.begin_create_or_update` has a new overload `def begin_create_or_update(self: None, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, endpoint_name: str, resource: IO[bytes], content_type: str)` + - Method `EndpointsOperations.begin_update` has a new overload `def begin_update(self: None, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, endpoint_name: str, properties: Endpoint, content_type: str)` + - Method `EndpointsOperations.begin_update` has a new overload `def begin_update(self: None, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, endpoint_name: str, properties: JSON, content_type: str)` + - Method `EndpointsOperations.begin_update` has a new overload `def begin_update(self: None, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, endpoint_name: str, properties: IO[bytes], content_type: str)` + - Method `NeonDatabasesOperations.begin_create_or_update` has a new overload `def begin_create_or_update(self: None, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, neon_database_name: str, resource: NeonDatabase, content_type: str)` + - Method `NeonDatabasesOperations.begin_create_or_update` has a new overload `def begin_create_or_update(self: None, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, neon_database_name: str, resource: JSON, content_type: str)` + - Method `NeonDatabasesOperations.begin_create_or_update` has a new overload `def begin_create_or_update(self: None, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, neon_database_name: str, resource: IO[bytes], content_type: str)` + - Method `NeonDatabasesOperations.begin_update` has a new overload `def begin_update(self: None, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, neon_database_name: str, properties: NeonDatabase, content_type: str)` + - Method `NeonDatabasesOperations.begin_update` has a new overload `def begin_update(self: None, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, neon_database_name: str, properties: JSON, content_type: str)` + - Method `NeonDatabasesOperations.begin_update` has a new overload `def begin_update(self: None, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, neon_database_name: str, properties: IO[bytes], content_type: str)` + - Method `NeonRolesOperations.begin_create_or_update` has a new overload `def begin_create_or_update(self: None, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, neon_role_name: str, resource: NeonRole, content_type: str)` + - Method `NeonRolesOperations.begin_create_or_update` has a new overload `def begin_create_or_update(self: None, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, neon_role_name: str, resource: JSON, content_type: str)` + - Method `NeonRolesOperations.begin_create_or_update` has a new overload `def begin_create_or_update(self: None, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, neon_role_name: str, resource: IO[bytes], content_type: str)` + - Method `NeonRolesOperations.begin_update` has a new overload `def begin_update(self: None, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, neon_role_name: str, properties: NeonRole, content_type: str)` + - Method `NeonRolesOperations.begin_update` has a new overload `def begin_update(self: None, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, neon_role_name: str, properties: JSON, content_type: str)` + - Method `NeonRolesOperations.begin_update` has a new overload `def begin_update(self: None, resource_group_name: str, organization_name: str, project_name: str, branch_name: str, neon_role_name: str, properties: IO[bytes], content_type: str)` + - Method `ProjectsOperations.begin_create_or_update` has a new overload `def begin_create_or_update(self: None, resource_group_name: str, organization_name: str, project_name: str, resource: Project, content_type: str)` + - Method `ProjectsOperations.begin_create_or_update` has a new overload `def begin_create_or_update(self: None, resource_group_name: str, organization_name: str, project_name: str, resource: JSON, content_type: str)` + - Method `ProjectsOperations.begin_create_or_update` has a new overload `def begin_create_or_update(self: None, resource_group_name: str, organization_name: str, project_name: str, resource: IO[bytes], content_type: str)` + - Method `ProjectsOperations.begin_update` has a new overload `def begin_update(self: None, resource_group_name: str, organization_name: str, project_name: str, properties: Project, content_type: str)` + - Method `ProjectsOperations.begin_update` has a new overload `def begin_update(self: None, resource_group_name: str, organization_name: str, project_name: str, properties: JSON, content_type: str)` + - Method `ProjectsOperations.begin_update` has a new overload `def begin_update(self: None, resource_group_name: str, organization_name: str, project_name: str, properties: IO[bytes], content_type: str)` + - Method `ProjectsOperations.get_connection_uri` has a new overload `def get_connection_uri(self: None, resource_group_name: str, organization_name: str, project_name: str, connection_uri_parameters: ConnectionUriProperties, content_type: str)` + - Method `ProjectsOperations.get_connection_uri` has a new overload `def get_connection_uri(self: None, resource_group_name: str, organization_name: str, project_name: str, connection_uri_parameters: JSON, content_type: str)` + - Method `ProjectsOperations.get_connection_uri` has a new overload `def get_connection_uri(self: None, resource_group_name: str, organization_name: str, project_name: str, connection_uri_parameters: IO[bytes], content_type: str)` + ## 1.0.0b1 (2024-12-03) ### Other Changes diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/README.md b/sdk/neonpostgres/azure-mgmt-neonpostgres/README.md index 4c1f85146d37..46b4ed1ef6f0 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/README.md +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/README.md @@ -24,7 +24,7 @@ pip install azure-identity ### Authentication -By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configure of following environment variables. +By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configuration of the following environment variables. - `AZURE_CLIENT_ID` for Azure client ID. - `AZURE_TENANT_ID` for Azure tenant ID. diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/_meta.json b/sdk/neonpostgres/azure-mgmt-neonpostgres/_meta.json index 2bd52a44f3d4..90a3c3a8a2be 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/_meta.json +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/_meta.json @@ -1,6 +1,6 @@ { - "commit": "4e3820497caa29ed0efada28a38cb4292cea9d55", + "commit": "af51fab0cc00ba3eaee7e4710e8fec5894d4bb0c", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "typespec_src": "specification/liftrneon/Neon.Postgres.Management", - "@azure-tools/typespec-python": "0.36.1" + "@azure-tools/typespec-python": "0.42.2" } \ 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 new file mode 100644 index 000000000000..33dfad20b8a1 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/apiview-properties.json @@ -0,0 +1,85 @@ +{ + "CrossLanguagePackageId": "Neon.Postgres", + "CrossLanguageDefinitionId": { + "azure.mgmt.neonpostgres.models.Attributes": "Neon.Postgres.Models.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.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.Endpoint": "Neon.Postgres.Endpoint", + "azure.mgmt.neonpostgres.models.EndpointProperties": "Neon.Postgres.Models.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.NeonRole": "Neon.Postgres.NeonRole", + "azure.mgmt.neonpostgres.models.NeonRoleProperties": "Neon.Postgres.Models.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", + "azure.mgmt.neonpostgres.models.OrganizationProperties": "LiftrBase.Data.OrganizationProperties", + "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.Project": "Neon.Postgres.Project", + "azure.mgmt.neonpostgres.models.ProjectProperties": "Neon.Postgres.Models.ProjectProperties", + "azure.mgmt.neonpostgres.models.SingleSignOnProperties": "LiftrBase.SingleSignOnProperties", + "azure.mgmt.neonpostgres.models.SystemData": "Azure.ResourceManager.CommonTypes.SystemData", + "azure.mgmt.neonpostgres.models.UserDetails": "LiftrBase.UserDetails", + "azure.mgmt.neonpostgres.models.Origin": "Azure.ResourceManager.CommonTypes.Origin", + "azure.mgmt.neonpostgres.models.ActionType": "Azure.ResourceManager.CommonTypes.ActionType", + "azure.mgmt.neonpostgres.models.CreatedByType": "Azure.ResourceManager.CommonTypes.createdByType", + "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" + } +} \ 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 dcfb281d2f77..7352f11880dc 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_client.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_client.py @@ -17,28 +17,51 @@ from ._configuration import NeonPostgresMgmtClientConfiguration from ._serialization import Deserializer, Serializer -from .operations import Operations, OrganizationsOperations +from .operations import ( + BranchesOperations, + ComputesOperations, + EndpointsOperations, + ModelsOperations, + NeonDatabasesOperations, + NeonRolesOperations, + Operations, + OrganizationsOperations, + ProjectsOperations, +) if TYPE_CHECKING: from azure.core.credentials import TokenCredential -class NeonPostgresMgmtClient: +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 :vartype organizations: azure.mgmt.neonpostgres.operations.OrganizationsOperations + :ivar projects: ProjectsOperations operations + :vartype projects: azure.mgmt.neonpostgres.operations.ProjectsOperations + :ivar branches: BranchesOperations operations + :vartype branches: azure.mgmt.neonpostgres.operations.BranchesOperations + :ivar computes: ComputesOperations operations + :vartype computes: azure.mgmt.neonpostgres.operations.ComputesOperations + :ivar neon_databases: NeonDatabasesOperations operations + :vartype neon_databases: azure.mgmt.neonpostgres.operations.NeonDatabasesOperations + :ivar neon_roles: NeonRolesOperations operations + :vartype neon_roles: azure.mgmt.neonpostgres.operations.NeonRolesOperations + :ivar endpoints: EndpointsOperations operations + :vartype endpoints: azure.mgmt.neonpostgres.operations.EndpointsOperations :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str :param base_url: Service host. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: The API version to use for this operation. Default value is - "2024-08-01-preview". Note that overriding this default value may result in unsupported - behavior. + :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. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -78,8 +101,15 @@ def __init__( 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) + self.branches = BranchesOperations(self._client, self._config, self._serialize, self._deserialize) + self.computes = ComputesOperations(self._client, self._config, self._serialize, self._deserialize) + self.neon_databases = NeonDatabasesOperations(self._client, self._config, self._serialize, self._deserialize) + self.neon_roles = NeonRolesOperations(self._client, self._config, self._serialize, self._deserialize) + self.endpoints = EndpointsOperations(self._client, self._config, self._serialize, self._deserialize) def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_configuration.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_configuration.py index 319ad0d33758..d4c6ec282c30 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_configuration.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_configuration.py @@ -29,9 +29,8 @@ class NeonPostgresMgmtClientConfiguration: # pylint: disable=too-many-instance- :type subscription_id: str :param base_url: Service host. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: The API version to use for this operation. Default value is - "2024-08-01-preview". Note that overriding this default value may result in unsupported - behavior. + :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. :paramtype api_version: str """ @@ -42,7 +41,7 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - api_version: str = kwargs.pop("api_version", "2024-08-01-preview") + api_version: str = kwargs.pop("api_version", "2025-03-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_model_base.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_model_base.py index e6a2730f9276..065b17f67c46 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_model_base.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_model_base.py @@ -2,8 +2,9 @@ # 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. +# 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. # -------------------------------------------------------------------------- # pylint: disable=protected-access, broad-except @@ -373,15 +374,34 @@ def __ne__(self, other: typing.Any) -> bool: return not self.__eq__(other) def keys(self) -> typing.KeysView[str]: + """ + :returns: a set-like object providing a view on D's keys + :rtype: ~typing.KeysView + """ return self._data.keys() def values(self) -> typing.ValuesView[typing.Any]: + """ + :returns: an object providing a view on D's values + :rtype: ~typing.ValuesView + """ return self._data.values() def items(self) -> typing.ItemsView[str, typing.Any]: + """ + :returns: set-like object providing a view on D's items + :rtype: ~typing.ItemsView + """ return self._data.items() def get(self, key: str, default: typing.Any = None) -> typing.Any: + """ + Get the value for key if key is in the dictionary, else default. + :param str key: The key to look up. + :param any default: The value to return if key is not in the dictionary. Defaults to None + :returns: D[k] if k in D, else d. + :rtype: any + """ try: return self[key] except KeyError: @@ -397,17 +417,38 @@ def pop(self, key: str, default: _T) -> _T: ... def pop(self, key: str, default: typing.Any) -> typing.Any: ... def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Removes specified key and return the corresponding value. + :param str key: The key to pop. + :param any default: The value to return if key is not in the dictionary + :returns: The value corresponding to the key. + :rtype: any + :raises KeyError: If key is not found and default is not given. + """ if default is _UNSET: return self._data.pop(key) return self._data.pop(key, default) def popitem(self) -> typing.Tuple[str, typing.Any]: + """ + Removes and returns some (key, value) pair + :returns: The (key, value) pair. + :rtype: tuple + :raises KeyError: if D is empty. + """ return self._data.popitem() def clear(self) -> None: + """ + Remove all items from D. + """ self._data.clear() def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: + """ + Updates D from mapping/iterable E and F. + :param any args: Either a mapping object or an iterable of key-value pairs. + """ self._data.update(*args, **kwargs) @typing.overload @@ -417,6 +458,13 @@ def setdefault(self, key: str, default: None = None) -> None: ... def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Same as calling D.get(k, d), and setting D[k]=d if k not found + :param str key: The key to look up. + :param any default: The value to set if key is not in the dictionary + :returns: D[k] if k in D, else d. + :rtype: any + """ if default is _UNSET: return self._data.setdefault(key) return self._data.setdefault(key, default) @@ -754,7 +802,7 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur except AttributeError: model_name = annotation if module is not None: - annotation = _get_model(module, model_name) + annotation = _get_model(module, model_name) # type: ignore try: if module and _is_model(annotation): @@ -894,6 +942,35 @@ def _deserialize( return _deserialize_with_callable(deserializer, value) +def _failsafe_deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + try: + return _deserialize(deserializer, value, module, rf, format) + except DeserializationError: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +def _failsafe_deserialize_xml( + deserializer: typing.Any, + value: typing.Any, +) -> typing.Any: + try: + return _deserialize_xml(deserializer, value) + except DeserializationError: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + class _RestField: def __init__( self, diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_patch.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_patch.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_serialization.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_serialization.py index ce17d1798ce7..eb86ea23c965 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_serialization.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_serialization.py @@ -1,28 +1,10 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pyright: reportUnnecessaryTypeIgnoreComment=false @@ -48,9 +30,7 @@ IO, Mapping, Callable, - TypeVar, MutableMapping, - Type, List, ) @@ -61,13 +41,13 @@ import xml.etree.ElementTree as ET import isodate # type: ignore +from typing_extensions import Self from azure.core.exceptions import DeserializationError, SerializationError from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") -ModelType = TypeVar("ModelType", bound="Model") JSON = MutableMapping[str, Any] @@ -185,73 +165,7 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], except NameError: _long_type = int - -class UTC(datetime.tzinfo): - """Time Zone info for handling UTC""" - - def utcoffset(self, dt): - """UTF offset for UTC is 0. - - :param datetime.datetime dt: The datetime - :returns: The offset - :rtype: datetime.timedelta - """ - return datetime.timedelta(0) - - def tzname(self, dt): - """Timestamp representation. - - :param datetime.datetime dt: The datetime - :returns: The timestamp representation - :rtype: str - """ - return "Z" - - def dst(self, dt): - """No daylight saving for UTC. - - :param datetime.datetime dt: The datetime - :returns: The daylight saving time - :rtype: datetime.timedelta - """ - return datetime.timedelta(hours=1) - - -try: - from datetime import timezone as _FixedOffset # type: ignore -except ImportError: # Python 2.7 - - class _FixedOffset(datetime.tzinfo): # type: ignore - """Fixed offset in minutes east from UTC. - Copy/pasted from Python doc - :param datetime.timedelta offset: offset in timedelta format - """ - - def __init__(self, offset) -> None: - self.__offset = offset - - def utcoffset(self, dt): - return self.__offset - - def tzname(self, dt): - return str(self.__offset.total_seconds() / 3600) - - def __repr__(self): - return "".format(self.tzname(None)) - - def dst(self, dt): - return datetime.timedelta(0) - - def __getinitargs__(self): - return (self.__offset,) - - -try: - from datetime import timezone - - TZ_UTC = timezone.utc -except ImportError: - TZ_UTC = UTC() # type: ignore +TZ_UTC = datetime.timezone.utc _FLATTEN = re.compile(r"(? ModelType: + def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: """Parse a str using the RestAPI syntax and return a model. :param str data: A str using RestAPI structure. JSON by default. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong - :rtype: ModelType + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( - cls: Type[ModelType], + cls, data: Any, key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, content_type: Optional[str] = None, - ) -> ModelType: + ) -> Self: """Parse a dict using given key extractor return a model. By default consider key @@ -479,8 +393,8 @@ def from_dict( :param function key_extractors: A key extractor function. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong - :rtype: ModelType + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) deserializer.key_extractors = ( # type: ignore @@ -563,7 +477,7 @@ def _decode_attribute_map_key(key): return key.replace("\\.", ".") -class Serializer(object): # pylint: disable=too-many-public-methods +class Serializer: # pylint: disable=too-many-public-methods """Request object model serializer.""" basic_types = {str: "str", int: "int", bool: "bool", float: "float"} @@ -626,7 +540,7 @@ def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, to :param object target_obj: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, dict - :raises: SerializationError if serialization fails. + :raises SerializationError: if serialization fails. :returns: The serialized data. """ key_transformer = kwargs.get("key_transformer", self.key_transformer) @@ -736,8 +650,8 @@ def body(self, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: dict - :raises: SerializationError if serialization fails. - :raises: ValueError if data is None + :raises SerializationError: if serialization fails. + :raises ValueError: if data is None :returns: The serialized request body """ @@ -781,8 +695,8 @@ def url(self, name, data, data_type, **kwargs): :param str data_type: The type to be serialized from. :rtype: str :returns: The serialized URL path - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None """ try: output = self.serialize_data(data, data_type, **kwargs) @@ -805,8 +719,8 @@ def query(self, name, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, list - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None :returns: The serialized query parameter """ try: @@ -835,8 +749,8 @@ def header(self, name, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None :returns: The serialized header """ try: @@ -855,9 +769,9 @@ def serialize_data(self, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :raises: AttributeError if required data is None. - :raises: ValueError if data is None - :raises: SerializationError if serialization fails. + :raises AttributeError: if required data is None. + :raises ValueError: if data is None + :raises SerializationError: if serialization fails. :returns: The serialized data. :rtype: str, int, float, bool, dict, list """ @@ -1192,7 +1106,7 @@ def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument :param Datetime attr: Object to be serialized. :rtype: str - :raises: TypeError if format invalid. + :raises TypeError: if format invalid. :return: serialized rfc """ try: @@ -1218,7 +1132,7 @@ def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument :param Datetime attr: Object to be serialized. :rtype: str - :raises: SerializationError if format invalid. + :raises SerializationError: if format invalid. :return: serialized iso """ if isinstance(attr, str): @@ -1251,7 +1165,7 @@ def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument :param Datetime attr: Object to be serialized. :rtype: int - :raises: SerializationError if format invalid + :raises SerializationError: if format invalid :return: serialied unix """ if isinstance(attr, int): @@ -1429,7 +1343,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) @@ -1441,7 +1355,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument return children[0] -class Deserializer(object): +class Deserializer: """Response object model deserializer. :param dict classes: Class type dictionary for deserializing complex types. @@ -1488,7 +1402,7 @@ def __call__(self, target_obj, response_data, content_type=None): :param str target_obj: Target data type to deserialize to. :param requests.Response response_data: REST response object. :param str content_type: Swagger "produces" if available. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. :rtype: object """ @@ -1502,7 +1416,7 @@ def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return :param str target_obj: Target data type to deserialize to. :param object data: Object to deserialize. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. :rtype: object """ @@ -1683,17 +1597,21 @@ def _instantiate_model(self, response, attrs, additional_properties=None): subtype = getattr(response, "_subtype_map", {}) try: readonly = [ - k for k, v in response._validation.items() if v.get("readonly") # pylint: disable=protected-access + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("readonly") ] const = [ - k for k, v in response._validation.items() if v.get("constant") # pylint: disable=protected-access + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("constant") ] kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} response_obj = response(**kwargs) for attr in readonly: setattr(response_obj, attr, attrs.get(attr)) if additional_properties: - response_obj.additional_properties = additional_properties + response_obj.additional_properties = additional_properties # type: ignore return response_obj except TypeError as err: msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore @@ -1713,7 +1631,7 @@ def deserialize_data(self, data, data_type): # pylint: disable=too-many-return- :param str data: The response string to be deserialized. :param str data_type: The type to deserialize to. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. :rtype: object """ @@ -1795,7 +1713,7 @@ def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return :param dict attr: Dictionary to be deserialized. :return: Deserialized object. :rtype: dict - :raises: TypeError if non-builtin datatype encountered. + :raises TypeError: if non-builtin datatype encountered. """ if attr is None: return None @@ -1841,7 +1759,7 @@ def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return :param str data_type: deserialization data type. :return: Deserialized basic type. :rtype: str, int, float or bool - :raises: TypeError if string format is not valid. + :raises TypeError: if string format is not valid. """ # If we're here, data is supposed to be a basic type. # If it's still an XML node, take the text @@ -1932,7 +1850,7 @@ def deserialize_bytearray(attr): :param str attr: response string to be deserialized. :return: Deserialized bytearray :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1945,7 +1863,7 @@ def deserialize_base64(attr): :param str attr: response string to be deserialized. :return: Deserialized base64 string :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1960,7 +1878,7 @@ def deserialize_decimal(attr): :param str attr: response string to be deserialized. :return: Deserialized decimal - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. :rtype: decimal """ if isinstance(attr, ET.Element): @@ -1978,7 +1896,7 @@ def deserialize_long(attr): :param str attr: response string to be deserialized. :return: Deserialized int :rtype: long or int - :raises: ValueError if string format invalid. + :raises ValueError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1991,7 +1909,7 @@ def deserialize_duration(attr): :param str attr: response string to be deserialized. :return: Deserialized duration :rtype: TimeDelta - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2009,7 +1927,7 @@ def deserialize_date(attr): :param str attr: response string to be deserialized. :return: Deserialized date :rtype: Date - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2025,7 +1943,7 @@ def deserialize_time(attr): :param str attr: response string to be deserialized. :return: Deserialized time :rtype: datetime.time - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2040,14 +1958,14 @@ def deserialize_rfc(attr): :param str attr: response string to be deserialized. :return: Deserialized RFC datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text try: parsed_date = email.utils.parsedate_tz(attr) # type: ignore date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) ) if not date_obj.tzinfo: date_obj = date_obj.astimezone(tz=TZ_UTC) @@ -2063,7 +1981,7 @@ def deserialize_iso(attr): :param str attr: response string to be deserialized. :return: Deserialized ISO datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2101,7 +2019,7 @@ def deserialize_unix(attr): :param int attr: Object to be serialized. :return: Deserialized datetime :rtype: Datetime - :raises: DeserializationError if format invalid + :raises DeserializationError: if format invalid """ if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_validation.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_validation.py new file mode 100644 index 000000000000..752b2822f9d3 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_validation.py @@ -0,0 +1,50 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import functools + + +def api_version_validation(**kwargs): + params_added_on = kwargs.pop("params_added_on", {}) + method_added_on = kwargs.pop("method_added_on", "") + + def decorator(func): + @functools.wraps(func) + def wrapper(*args, **kwargs): + try: + # this assumes the client has an _api_version attribute + client = args[0] + client_api_version = client._config.api_version # pylint: disable=protected-access + except AttributeError: + return func(*args, **kwargs) + + if method_added_on > client_api_version: + raise ValueError( + f"'{func.__name__}' is not available in API version " + f"{client_api_version}. Pass service API version {method_added_on} or newer to your client." + ) + + unsupported = { + parameter: api_version + for api_version, parameters in params_added_on.items() + for parameter in parameters + if parameter in kwargs and api_version > client_api_version + } + if unsupported: + raise ValueError( + "".join( + [ + f"'{param}' is not available in API version {client_api_version}. " + f"Use service API version {version} or newer.\n" + for param, version in unsupported.items() + ] + ) + ) + return func(*args, **kwargs) + + return wrapper + + return decorator 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 be71c81bd282..0ec13ea52bbf 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.0b1" +VERSION = "1.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 5c3117d9acd1..98a430bde872 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 @@ -17,28 +17,51 @@ from .._serialization import Deserializer, Serializer from ._configuration import NeonPostgresMgmtClientConfiguration -from .operations import Operations, OrganizationsOperations +from .operations import ( + BranchesOperations, + ComputesOperations, + EndpointsOperations, + ModelsOperations, + NeonDatabasesOperations, + NeonRolesOperations, + Operations, + OrganizationsOperations, + ProjectsOperations, +) if TYPE_CHECKING: from azure.core.credentials_async import AsyncTokenCredential -class NeonPostgresMgmtClient: +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 :vartype organizations: azure.mgmt.neonpostgres.aio.operations.OrganizationsOperations + :ivar projects: ProjectsOperations operations + :vartype projects: azure.mgmt.neonpostgres.aio.operations.ProjectsOperations + :ivar branches: BranchesOperations operations + :vartype branches: azure.mgmt.neonpostgres.aio.operations.BranchesOperations + :ivar computes: ComputesOperations operations + :vartype computes: azure.mgmt.neonpostgres.aio.operations.ComputesOperations + :ivar neon_databases: NeonDatabasesOperations operations + :vartype neon_databases: azure.mgmt.neonpostgres.aio.operations.NeonDatabasesOperations + :ivar neon_roles: NeonRolesOperations operations + :vartype neon_roles: azure.mgmt.neonpostgres.aio.operations.NeonRolesOperations + :ivar endpoints: EndpointsOperations operations + :vartype endpoints: azure.mgmt.neonpostgres.aio.operations.EndpointsOperations :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str :param base_url: Service host. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: The API version to use for this operation. Default value is - "2024-08-01-preview". Note that overriding this default value may result in unsupported - behavior. + :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. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -78,8 +101,15 @@ def __init__( 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) + self.branches = BranchesOperations(self._client, self._config, self._serialize, self._deserialize) + self.computes = ComputesOperations(self._client, self._config, self._serialize, self._deserialize) + self.neon_databases = NeonDatabasesOperations(self._client, self._config, self._serialize, self._deserialize) + self.neon_roles = NeonRolesOperations(self._client, self._config, self._serialize, self._deserialize) + self.endpoints = EndpointsOperations(self._client, self._config, self._serialize, self._deserialize) def send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/aio/_configuration.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/aio/_configuration.py index fec564b33f32..28901e3c6229 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/aio/_configuration.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/aio/_configuration.py @@ -29,9 +29,8 @@ class NeonPostgresMgmtClientConfiguration: # pylint: disable=too-many-instance- :type subscription_id: str :param base_url: Service host. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: The API version to use for this operation. Default value is - "2024-08-01-preview". Note that overriding this default value may result in unsupported - behavior. + :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. :paramtype api_version: str """ @@ -42,7 +41,7 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - api_version: str = kwargs.pop("api_version", "2024-08-01-preview") + api_version: str = kwargs.pop("api_version", "2025-03-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/aio/_patch.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/aio/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/aio/_patch.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/aio/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize 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 72e76f8318ab..2828a5d7896d 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,16 +12,30 @@ 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 +from ._operations import BranchesOperations # type: ignore +from ._operations import ComputesOperations # type: ignore +from ._operations import NeonDatabasesOperations # type: ignore +from ._operations import NeonRolesOperations # type: ignore +from ._operations import EndpointsOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ + "ModelsOperations", "Operations", "OrganizationsOperations", + "ProjectsOperations", + "BranchesOperations", + "ComputesOperations", + "NeonDatabasesOperations", + "NeonRolesOperations", + "EndpointsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() 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 72ce5d8b11e9..b193d5581019 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 @@ -12,6 +12,7 @@ from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload import urllib.parse +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -33,16 +34,51 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._model_base import SdkJSONEncoder, _deserialize +from ..._model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize +from ..._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, + build_organizations_get_postgres_versions_request, build_organizations_get_request, build_organizations_list_by_resource_group_request, build_organizations_list_by_subscription_request, build_organizations_update_request, + build_projects_create_or_update_request, + build_projects_delete_request, + 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 @@ -53,6 +89,24 @@ 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") + + class Operations: """ .. warning:: @@ -65,10 +119,10 @@ class Operations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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) -> AsyncIterable["_models.Operation"]: @@ -130,7 +184,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Operation], deserialized["value"]) + 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, AsyncList(list_of_elem) @@ -146,7 +200,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -166,10 +220,10 @@ class OrganizationsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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 async def get( @@ -226,7 +280,7 @@ async def get( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if _stream: @@ -295,7 +349,7 @@ async def _create_or_update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -531,7 +585,7 @@ async def _update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -751,7 +805,7 @@ async def _delete_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -893,7 +947,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.OrganizationResource], deserialized["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, AsyncList(list_of_elem) @@ -909,7 +963,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -978,7 +1032,5786 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.OrganizationResource], deserialized["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, 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 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 + async 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 + async 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_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", "content_type", "accept"] + }, + ) + async 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 = 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.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.aio.NeonPostgresMgmtClient`'s + :attr:`projects` 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", + "accept", + ] + }, + ) + async 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 = 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.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", + ] + }, + ) + async 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 + ) -> 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_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 = 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, + resource: _models.Project, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_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 AsyncLROPoller that returns Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async 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 + ) -> AsyncLROPoller[_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 AsyncLROPoller that returns Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async 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 + ) -> AsyncLROPoller[_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 AsyncLROPoller that returns Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Project] + :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", + "content_type", + "accept", + ] + }, + ) + async 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 + ) -> AsyncLROPoller[_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 AsyncLROPoller that returns Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~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, 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, + 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.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: 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 + ) + + @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", + ] + }, + ) + 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]: + 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_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 = 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, + properties: _models.Project, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_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 AsyncLROPoller that returns Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_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 AsyncLROPoller that returns Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_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 AsyncLROPoller that returns Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.neonpostgres.models.Project] + :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", + "content_type", + "accept", + ] + }, + ) + async def begin_update( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + properties: Union[_models.Project, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_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 AsyncLROPoller that returns Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~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, 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) + + 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: 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 + ) + + @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", + "accept", + ] + }, + ) + 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, + 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 = 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", + "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) + + 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 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 + async 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 + async 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_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", + "content_type", + "accept", + ] + }, + ) + async 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 = 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", + params_added_on={ + "2025-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + "branch_name", + "accept", + ] + }, + ) + 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. + :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 = 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.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", + ] + }, + ) + 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 {} + + 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_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 = 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, + resource: _models.Branch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_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 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: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_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 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. + + :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: + """ + + @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_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. + + :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 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._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 + ) + + @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, + 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_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 = 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, + properties: _models.Branch, + *, + 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: ~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: + """ + + @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 + ) + + @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, + 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_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: + """ + + @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. + + :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 {} + + 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) + + 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 + ) + + @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 delete( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + branch_name: str, + endpoint_name: str, + **kwargs: Any + ) -> None: + """Delete 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: 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_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) + + _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.Endpoint"]: + """List Endpoint 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 Endpoint + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.neonpostgres.models.Endpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Endpoint]] = 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_endpoints_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.Endpoint], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -994,7 +6827,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/aio/operations/_patch.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/aio/operations/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/aio/operations/_patch.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/aio/operations/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/models/__init__.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/models/__init__.py index 0030bf5b084c..89467d9635f5 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/models/__init__.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/models/__init__.py @@ -14,17 +14,35 @@ from ._models import ( # type: ignore + Attributes, + Branch, + BranchProperties, CompanyDetails, + Compute, + ComputeProperties, + ConnectionUriProperties, + DefaultEndpointSettings, + Endpoint, + EndpointProperties, ErrorAdditionalInfo, ErrorDetail, ErrorResponse, MarketplaceDetails, + NeonDatabase, + NeonDatabaseProperties, + NeonRole, + NeonRoleProperties, OfferDetails, Operation, OperationDisplay, OrganizationProperties, OrganizationResource, PartnerOrganizationProperties, + PgVersion, + PgVersionsResult, + Project, + ProjectProperties, + ProxyResource, Resource, SingleSignOnProperties, SystemData, @@ -35,6 +53,7 @@ from ._enums import ( # type: ignore ActionType, CreatedByType, + EndpointType, MarketplaceSubscriptionStatus, Origin, ResourceProvisioningState, @@ -45,17 +64,35 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ + "Attributes", + "Branch", + "BranchProperties", "CompanyDetails", + "Compute", + "ComputeProperties", + "ConnectionUriProperties", + "DefaultEndpointSettings", + "Endpoint", + "EndpointProperties", "ErrorAdditionalInfo", "ErrorDetail", "ErrorResponse", "MarketplaceDetails", + "NeonDatabase", + "NeonDatabaseProperties", + "NeonRole", + "NeonRoleProperties", "OfferDetails", "Operation", "OperationDisplay", "OrganizationProperties", "OrganizationResource", "PartnerOrganizationProperties", + "PgVersion", + "PgVersionsResult", + "Project", + "ProjectProperties", + "ProxyResource", "Resource", "SingleSignOnProperties", "SystemData", @@ -63,6 +100,7 @@ "UserDetails", "ActionType", "CreatedByType", + "EndpointType", "MarketplaceSubscriptionStatus", "Origin", "ResourceProvisioningState", diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/models/_enums.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/models/_enums.py index 8ec7e3b87180..96f2b8f22bcb 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/models/_enums.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/models/_enums.py @@ -32,6 +32,15 @@ class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The entity was created by a key.""" +class EndpointType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The compute endpoint type. Either read_write or read_only.""" + + READ_ONLY = "read_only" + """ReadOnly compute endpoint type""" + READ_WRITE = "read_write" + """ReadWrite compute endpoint type""" + + class MarketplaceSubscriptionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Marketplace subscription status of a resource.""" 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 cb50196e6ee8..5342946f4ece 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 @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -17,6 +18,222 @@ from .. import models as _models +class Attributes(_model_base.Model): + """Additional attributes specific to Neon Resources. + + :ivar name: Name of the attribute. Required. + :vartype name: str + :ivar value: Value of the attribute. Required. + :vartype value: str + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of the attribute. Required.""" + value: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Value of the attribute. Required.""" + + @overload + def __init__( + self, + *, + name: str, + value: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Resource(_model_base.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 - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.neonpostgres.models.SystemData + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.""" + name: Optional[str] = rest_field(visibility=["read"]) + """The name of the resource.""" + type: Optional[str] = rest_field(visibility=["read"]) + """The type of the resource. E.g. \"Microsoft.Compute/virtualMachines\" or + \"Microsoft.Storage/storageAccounts\".""" + system_data: Optional["_models.SystemData"] = rest_field(name="systemData", visibility=["read"]) + """Azure Resource Manager metadata containing createdBy and modifiedBy information.""" + + +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have + tags and a location. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.neonpostgres.models.SystemData + """ + + +class Branch(ProxyResource): + """The Branch resource type. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.neonpostgres.models.SystemData + :ivar properties: The resource-specific properties for this resource. + :vartype properties: ~azure.mgmt.neonpostgres.models.BranchProperties + """ + + properties: Optional["_models.BranchProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The resource-specific properties for this resource.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.BranchProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BranchProperties(_model_base.Model): + """Properties specific to Branch. + + :ivar entity_id: Unique identifier for the entity. + :vartype entity_id: str + :ivar entity_name: Name of the resource. + :vartype entity_name: str + :ivar created_at: Timestamp indicating when the entity was created. + :vartype created_at: str + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Succeeded", + "Failed", and "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.neonpostgres.models.ResourceProvisioningState + :ivar attributes: Additional attributes for the entity. + :vartype attributes: list[~azure.mgmt.neonpostgres.models.Attributes] + :ivar project_id: The ID of the project this branch belongs to. + :vartype project_id: str + :ivar parent_id: The ID of the parent branch. + :vartype parent_id: str + :ivar role_name: Role name associated with the branch. + :vartype role_name: str + :ivar database_name: Database name associated with the branch. + :vartype database_name: str + :ivar roles: Roles associated with the branch. + :vartype roles: list[~azure.mgmt.neonpostgres.models.NeonRoleProperties] + :ivar databases: Neon Databases associated with the branch. + :vartype databases: list[~azure.mgmt.neonpostgres.models.NeonDatabaseProperties] + :ivar endpoints: Endpoints associated with the branch. + :vartype endpoints: list[~azure.mgmt.neonpostgres.models.EndpointProperties] + """ + + entity_id: Optional[str] = rest_field(name="entityId", visibility=["read"]) + """Unique identifier for the entity.""" + entity_name: Optional[str] = rest_field( + name="entityName", visibility=["read", "create", "update", "delete", "query"] + ) + """Name of the resource.""" + created_at: Optional[str] = rest_field(name="createdAt", visibility=["read"]) + """Timestamp indicating when the entity was created.""" + provisioning_state: Optional[Union[str, "_models.ResourceProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state of the resource. Known values are: \"Succeeded\", \"Failed\", and + \"Canceled\".""" + attributes: Optional[List["_models.Attributes"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Additional attributes for the entity.""" + project_id: Optional[str] = rest_field(name="projectId", visibility=["read", "create", "update", "delete", "query"]) + """The ID of the project this branch belongs to.""" + parent_id: Optional[str] = rest_field(name="parentId", visibility=["read", "create", "update", "delete", "query"]) + """The ID of the parent branch.""" + role_name: Optional[str] = rest_field(name="roleName", visibility=["read", "create", "update", "delete", "query"]) + """Role name associated with the branch.""" + database_name: Optional[str] = rest_field( + name="databaseName", visibility=["read", "create", "update", "delete", "query"] + ) + """Database name associated with the branch.""" + roles: Optional[List["_models.NeonRoleProperties"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Roles associated with the branch.""" + databases: Optional[List["_models.NeonDatabaseProperties"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Neon Databases associated with the branch.""" + endpoints: Optional[List["_models.EndpointProperties"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Endpoints associated with the branch.""" + + @overload + def __init__( + self, + *, + entity_name: Optional[str] = None, + attributes: Optional[List["_models.Attributes"]] = None, + project_id: Optional[str] = None, + parent_id: Optional[str] = None, + role_name: Optional[str] = None, + database_name: Optional[str] = None, + roles: Optional[List["_models.NeonRoleProperties"]] = None, + databases: Optional[List["_models.NeonDatabaseProperties"]] = None, + endpoints: Optional[List["_models.EndpointProperties"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + class CompanyDetails(_model_base.Model): """Company details for an organization. @@ -34,17 +251,25 @@ class CompanyDetails(_model_base.Model): :vartype number_of_employees: int """ - company_name: Optional[str] = rest_field(name="companyName") + company_name: Optional[str] = rest_field( + name="companyName", visibility=["read", "create", "update", "delete", "query"] + ) """Company name.""" - country: Optional[str] = rest_field() + country: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Country name of the company.""" - office_address: Optional[str] = rest_field(name="officeAddress") + office_address: Optional[str] = rest_field( + name="officeAddress", visibility=["read", "create", "update", "delete", "query"] + ) """Office address of the company.""" - business_phone: Optional[str] = rest_field(name="businessPhone") + business_phone: Optional[str] = rest_field( + name="businessPhone", visibility=["read", "create", "update", "delete", "query"] + ) """Business phone number of the company.""" - domain: Optional[str] = rest_field() + domain: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Domain of the user.""" - number_of_employees: Optional[int] = rest_field(name="numberOfEmployees") + number_of_employees: Optional[int] = rest_field( + name="numberOfEmployees", visibility=["read", "create", "update", "delete", "query"] + ) """Number of employees in the company.""" @overload @@ -70,11 +295,332 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) +class Compute(ProxyResource): + """The Compute resource type. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.neonpostgres.models.SystemData + :ivar properties: The resource-specific properties for this resource. + :vartype properties: ~azure.mgmt.neonpostgres.models.ComputeProperties + """ + + properties: Optional["_models.ComputeProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The resource-specific properties for this resource.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.ComputeProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ComputeProperties(_model_base.Model): + """Properties specific to Compute. + + :ivar entity_id: Unique identifier for the entity. + :vartype entity_id: str + :ivar entity_name: Name of the resource. + :vartype entity_name: str + :ivar created_at: Timestamp indicating when the entity was created. + :vartype created_at: str + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Succeeded", + "Failed", and "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.neonpostgres.models.ResourceProvisioningState + :ivar attributes: Additional attributes for the entity. + :vartype attributes: list[~azure.mgmt.neonpostgres.models.Attributes] + :ivar region: Region where the compute instance is located. + :vartype region: str + :ivar cpu_cores: Number of allocated CPU cores. + :vartype cpu_cores: int + :ivar memory: Memory allocated in GB. + :vartype memory: int + :ivar status: Current status of the compute instance. + :vartype status: str + """ + + entity_id: Optional[str] = rest_field(name="entityId", visibility=["read"]) + """Unique identifier for the entity.""" + entity_name: Optional[str] = rest_field( + name="entityName", visibility=["read", "create", "update", "delete", "query"] + ) + """Name of the resource.""" + created_at: Optional[str] = rest_field(name="createdAt", visibility=["read"]) + """Timestamp indicating when the entity was created.""" + provisioning_state: Optional[Union[str, "_models.ResourceProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state of the resource. Known values are: \"Succeeded\", \"Failed\", and + \"Canceled\".""" + attributes: Optional[List["_models.Attributes"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Additional attributes for the entity.""" + region: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Region where the compute instance is located.""" + cpu_cores: Optional[int] = rest_field(name="cpuCores", visibility=["read", "create", "update", "delete", "query"]) + """Number of allocated CPU cores.""" + memory: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Memory allocated in GB.""" + status: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Current status of the compute instance.""" + + @overload + def __init__( + self, + *, + entity_name: Optional[str] = None, + attributes: Optional[List["_models.Attributes"]] = None, + region: Optional[str] = None, + cpu_cores: Optional[int] = None, + memory: Optional[int] = None, + status: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ConnectionUriProperties(_model_base.Model): + """Connection uri parameters for the associated database. + + :ivar project_id: Project Id associated with this connection. + :vartype project_id: str + :ivar branch_id: Branch Id associated with this connection. + :vartype branch_id: str + :ivar database_name: Database name associated with this connection. + :vartype database_name: str + :ivar role_name: The role name used for authentication. + :vartype role_name: str + :ivar endpoint_id: the endpoint Id with this connection. + :vartype endpoint_id: str + :ivar is_pooled: Indicates if the connection is pooled. + :vartype is_pooled: bool + :ivar connection_string_uri: connection uri returned for the database. + :vartype connection_string_uri: str + """ + + project_id: Optional[str] = rest_field(name="projectId", visibility=["read", "create", "update", "delete", "query"]) + """Project Id associated with this connection.""" + branch_id: Optional[str] = rest_field(name="branchId", visibility=["read", "create", "update", "delete", "query"]) + """Branch Id associated with this connection.""" + database_name: Optional[str] = rest_field( + name="databaseName", visibility=["read", "create", "update", "delete", "query"] + ) + """Database name associated with this connection.""" + role_name: Optional[str] = rest_field(name="roleName", visibility=["read", "create", "update", "delete", "query"]) + """The role name used for authentication.""" + endpoint_id: Optional[str] = rest_field( + name="endpointId", visibility=["read", "create", "update", "delete", "query"] + ) + """the endpoint Id with this connection.""" + is_pooled: Optional[bool] = rest_field(name="isPooled", visibility=["read", "create", "update", "delete", "query"]) + """Indicates if the connection is pooled.""" + connection_string_uri: Optional[str] = rest_field(name="connectionStringUri", visibility=["read"]) + """connection uri returned for the database.""" + + @overload + def __init__( + self, + *, + project_id: Optional[str] = None, + branch_id: Optional[str] = None, + database_name: Optional[str] = None, + role_name: Optional[str] = None, + endpoint_id: Optional[str] = None, + is_pooled: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DefaultEndpointSettings(_model_base.Model): + """Default Endpoint Settings for the project. + + :ivar autoscaling_limit_min_cu: Minimum compute units for autoscaling. Required. + :vartype autoscaling_limit_min_cu: float + :ivar autoscaling_limit_max_cu: Maximum compute units for autoscaling. Required. + :vartype autoscaling_limit_max_cu: float + """ + + autoscaling_limit_min_cu: float = rest_field( + name="autoscalingLimitMinCu", visibility=["read", "create", "update", "delete", "query"] + ) + """Minimum compute units for autoscaling. Required.""" + autoscaling_limit_max_cu: float = rest_field( + name="autoscalingLimitMaxCu", visibility=["read", "create", "update", "delete", "query"] + ) + """Maximum compute units for autoscaling. Required.""" + + @overload + def __init__( + self, + *, + autoscaling_limit_min_cu: float, + autoscaling_limit_max_cu: float, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Endpoint(ProxyResource): + """The Neon compute endpoint resource type. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.neonpostgres.models.SystemData + :ivar properties: The resource-specific properties for this resource. + :vartype properties: ~azure.mgmt.neonpostgres.models.EndpointProperties + """ + + properties: Optional["_models.EndpointProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The resource-specific properties for this resource.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.EndpointProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class EndpointProperties(_model_base.Model): + """Properties specific to Endpoints. + + :ivar entity_id: Unique identifier for the entity. + :vartype entity_id: str + :ivar entity_name: Name of the resource. + :vartype entity_name: str + :ivar created_at: Timestamp indicating when the entity was created. + :vartype created_at: str + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Succeeded", + "Failed", and "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.neonpostgres.models.ResourceProvisioningState + :ivar attributes: Additional attributes for the entity. + :vartype attributes: list[~azure.mgmt.neonpostgres.models.Attributes] + :ivar project_id: The ID of the project this endpoint belongs to. + :vartype project_id: str + :ivar branch_id: The ID of the branch this endpoint belongs to. + :vartype branch_id: str + :ivar endpoint_type: The type of the endpoint. Known values are: "read_only" and "read_write". + :vartype endpoint_type: str or ~azure.mgmt.neonpostgres.models.EndpointType + """ + + entity_id: Optional[str] = rest_field(name="entityId", visibility=["read"]) + """Unique identifier for the entity.""" + entity_name: Optional[str] = rest_field( + name="entityName", visibility=["read", "create", "update", "delete", "query"] + ) + """Name of the resource.""" + created_at: Optional[str] = rest_field(name="createdAt", visibility=["read"]) + """Timestamp indicating when the entity was created.""" + provisioning_state: Optional[Union[str, "_models.ResourceProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state of the resource. Known values are: \"Succeeded\", \"Failed\", and + \"Canceled\".""" + attributes: Optional[List["_models.Attributes"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Additional attributes for the entity.""" + project_id: Optional[str] = rest_field(name="projectId", visibility=["read", "create", "update", "delete", "query"]) + """The ID of the project this endpoint belongs to.""" + branch_id: Optional[str] = rest_field(name="branchId", visibility=["read", "create", "update", "delete", "query"]) + """The ID of the branch this endpoint belongs to.""" + endpoint_type: Optional[Union[str, "_models.EndpointType"]] = rest_field( + name="endpointType", visibility=["read", "create", "update", "delete", "query"] + ) + """The type of the endpoint. Known values are: \"read_only\" and \"read_write\".""" + + @overload + def __init__( + self, + *, + entity_name: Optional[str] = None, + attributes: Optional[List["_models.Attributes"]] = None, + project_id: Optional[str] = None, + branch_id: Optional[str] = None, + endpoint_type: Optional[Union[str, "_models.EndpointType"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + class ErrorAdditionalInfo(_model_base.Model): """The resource management error additional info. - Readonly variables are only populated by the server, and will be ignored when sending a request. - :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. @@ -90,8 +636,6 @@ class ErrorAdditionalInfo(_model_base.Model): class ErrorDetail(_model_base.Model): """The error detail. - Readonly variables are only populated by the server, and will be ignored when sending a request. - :ivar code: The error code. :vartype code: str :ivar message: The error message. @@ -104,36 +648,228 @@ class ErrorDetail(_model_base.Model): :vartype additional_info: list[~azure.mgmt.neonpostgres.models.ErrorAdditionalInfo] """ - code: Optional[str] = rest_field(visibility=["read"]) - """The error code.""" - message: Optional[str] = rest_field(visibility=["read"]) - """The error message.""" - target: Optional[str] = rest_field(visibility=["read"]) - """The error target.""" - details: Optional[List["_models.ErrorDetail"]] = rest_field(visibility=["read"]) - """The error details.""" - additional_info: Optional[List["_models.ErrorAdditionalInfo"]] = rest_field( - name="additionalInfo", visibility=["read"] + code: Optional[str] = rest_field(visibility=["read"]) + """The error code.""" + message: Optional[str] = rest_field(visibility=["read"]) + """The error message.""" + target: Optional[str] = rest_field(visibility=["read"]) + """The error target.""" + details: Optional[List["_models.ErrorDetail"]] = rest_field(visibility=["read"]) + """The error details.""" + additional_info: Optional[List["_models.ErrorAdditionalInfo"]] = rest_field( + name="additionalInfo", visibility=["read"] + ) + """The error additional info.""" + + +class ErrorResponse(_model_base.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. + + :ivar error: The error object. + :vartype error: ~azure.mgmt.neonpostgres.models.ErrorDetail + """ + + error: Optional["_models.ErrorDetail"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The error object.""" + + @overload + def __init__( + self, + *, + error: Optional["_models.ErrorDetail"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MarketplaceDetails(_model_base.Model): + """Marketplace details for an organization. + + :ivar subscription_id: SaaS subscription id for the the marketplace offer. + :vartype subscription_id: str + :ivar subscription_status: Marketplace subscription status. Known values are: + "PendingFulfillmentStart", "Subscribed", "Suspended", and "Unsubscribed". + :vartype subscription_status: str or + ~azure.mgmt.neonpostgres.models.MarketplaceSubscriptionStatus + :ivar offer_details: Offer details for the marketplace that is selected by the user. Required. + :vartype offer_details: ~azure.mgmt.neonpostgres.models.OfferDetails + """ + + subscription_id: Optional[str] = rest_field( + name="subscriptionId", visibility=["read", "create", "update", "delete", "query"] + ) + """SaaS subscription id for the the marketplace offer.""" + subscription_status: Optional[Union[str, "_models.MarketplaceSubscriptionStatus"]] = rest_field( + name="subscriptionStatus", visibility=["read", "create", "update", "delete", "query"] + ) + """Marketplace subscription status. Known values are: \"PendingFulfillmentStart\", \"Subscribed\", + \"Suspended\", and \"Unsubscribed\".""" + offer_details: "_models.OfferDetails" = rest_field( + name="offerDetails", visibility=["read", "create", "update", "delete", "query"] + ) + """Offer details for the marketplace that is selected by the user. Required.""" + + @overload + def __init__( + self, + *, + offer_details: "_models.OfferDetails", + subscription_id: Optional[str] = None, + subscription_status: Optional[Union[str, "_models.MarketplaceSubscriptionStatus"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NeonDatabase(ProxyResource): + """The Neon Database resource type. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.neonpostgres.models.SystemData + :ivar properties: The resource-specific properties for this resource. + :vartype properties: ~azure.mgmt.neonpostgres.models.NeonDatabaseProperties + """ + + properties: Optional["_models.NeonDatabaseProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The resource-specific properties for this resource.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.NeonDatabaseProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NeonDatabaseProperties(_model_base.Model): + """Properties specific to Databases. + + :ivar entity_id: Unique identifier for the entity. + :vartype entity_id: str + :ivar entity_name: Name of the resource. + :vartype entity_name: str + :ivar created_at: Timestamp indicating when the entity was created. + :vartype created_at: str + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Succeeded", + "Failed", and "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.neonpostgres.models.ResourceProvisioningState + :ivar attributes: Additional attributes for the entity. + :vartype attributes: list[~azure.mgmt.neonpostgres.models.Attributes] + :ivar branch_id: The ID of the branch this database belongs to. + :vartype branch_id: str + :ivar owner_name: The name of the role that owns the database. + :vartype owner_name: str + """ + + entity_id: Optional[str] = rest_field(name="entityId", visibility=["read"]) + """Unique identifier for the entity.""" + entity_name: Optional[str] = rest_field( + name="entityName", visibility=["read", "create", "update", "delete", "query"] ) - """The error additional info.""" + """Name of the resource.""" + created_at: Optional[str] = rest_field(name="createdAt", visibility=["read"]) + """Timestamp indicating when the entity was created.""" + provisioning_state: Optional[Union[str, "_models.ResourceProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state of the resource. Known values are: \"Succeeded\", \"Failed\", and + \"Canceled\".""" + attributes: Optional[List["_models.Attributes"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Additional attributes for the entity.""" + branch_id: Optional[str] = rest_field(name="branchId", visibility=["read", "create", "update", "delete", "query"]) + """The ID of the branch this database belongs to.""" + owner_name: Optional[str] = rest_field(name="ownerName", visibility=["read", "create", "update", "delete", "query"]) + """The name of the role that owns the database.""" + @overload + def __init__( + self, + *, + entity_name: Optional[str] = None, + attributes: Optional[List["_models.Attributes"]] = None, + branch_id: Optional[str] = None, + owner_name: Optional[str] = None, + ) -> None: ... -class ErrorResponse(_model_base.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ - :ivar error: The error object. - :vartype error: ~azure.mgmt.neonpostgres.models.ErrorDetail + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NeonRole(ProxyResource): + """The Neon Role resource type. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.neonpostgres.models.SystemData + :ivar properties: The resource-specific properties for this resource. + :vartype properties: ~azure.mgmt.neonpostgres.models.NeonRoleProperties """ - error: Optional["_models.ErrorDetail"] = rest_field() - """The error object.""" + properties: Optional["_models.NeonRoleProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The resource-specific properties for this resource.""" @overload def __init__( self, *, - error: Optional["_models.ErrorDetail"] = None, + properties: Optional["_models.NeonRoleProperties"] = None, ) -> None: ... @overload @@ -147,37 +883,63 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class MarketplaceDetails(_model_base.Model): - """Marketplace details for an organization. - +class NeonRoleProperties(_model_base.Model): + """Properties specific to Roles. - :ivar subscription_id: SaaS subscription id for the the marketplace offer. - :vartype subscription_id: str - :ivar subscription_status: Marketplace subscription status. Known values are: - "PendingFulfillmentStart", "Subscribed", "Suspended", and "Unsubscribed". - :vartype subscription_status: str or - ~azure.mgmt.neonpostgres.models.MarketplaceSubscriptionStatus - :ivar offer_details: Offer details for the marketplace that is selected by the user. Required. - :vartype offer_details: ~azure.mgmt.neonpostgres.models.OfferDetails + :ivar entity_id: Unique identifier for the entity. + :vartype entity_id: str + :ivar entity_name: Name of the resource. + :vartype entity_name: str + :ivar created_at: Timestamp indicating when the entity was created. + :vartype created_at: str + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Succeeded", + "Failed", and "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.neonpostgres.models.ResourceProvisioningState + :ivar attributes: Additional attributes for the entity. + :vartype attributes: list[~azure.mgmt.neonpostgres.models.Attributes] + :ivar branch_id: The ID of the branch this role belongs to. + :vartype branch_id: str + :ivar permissions: Permissions assigned to the role. + :vartype permissions: list[str] + :ivar is_super_user: Indicates whether the role has superuser privileges. + :vartype is_super_user: bool """ - subscription_id: Optional[str] = rest_field(name="subscriptionId") - """SaaS subscription id for the the marketplace offer.""" - subscription_status: Optional[Union[str, "_models.MarketplaceSubscriptionStatus"]] = rest_field( - name="subscriptionStatus" + entity_id: Optional[str] = rest_field(name="entityId", visibility=["read"]) + """Unique identifier for the entity.""" + entity_name: Optional[str] = rest_field( + name="entityName", visibility=["read", "create", "update", "delete", "query"] ) - """Marketplace subscription status. Known values are: \"PendingFulfillmentStart\", \"Subscribed\", - \"Suspended\", and \"Unsubscribed\".""" - offer_details: "_models.OfferDetails" = rest_field(name="offerDetails") - """Offer details for the marketplace that is selected by the user. Required.""" + """Name of the resource.""" + created_at: Optional[str] = rest_field(name="createdAt", visibility=["read"]) + """Timestamp indicating when the entity was created.""" + provisioning_state: Optional[Union[str, "_models.ResourceProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state of the resource. Known values are: \"Succeeded\", \"Failed\", and + \"Canceled\".""" + attributes: Optional[List["_models.Attributes"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Additional attributes for the entity.""" + branch_id: Optional[str] = rest_field(name="branchId", visibility=["read", "create", "update", "delete", "query"]) + """The ID of the branch this role belongs to.""" + permissions: Optional[List[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Permissions assigned to the role.""" + is_super_user: Optional[bool] = rest_field( + name="isSuperUser", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates whether the role has superuser privileges.""" @overload def __init__( self, *, - offer_details: "_models.OfferDetails", - subscription_id: Optional[str] = None, - subscription_status: Optional[Union[str, "_models.MarketplaceSubscriptionStatus"]] = None, + entity_name: Optional[str] = None, + attributes: Optional[List["_models.Attributes"]] = None, + branch_id: Optional[str] = None, + permissions: Optional[List[str]] = None, + is_super_user: Optional[bool] = None, ) -> None: ... @overload @@ -194,7 +956,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class OfferDetails(_model_base.Model): """Offer details for the marketplace that is selected by the user. - :ivar publisher_id: Publisher Id for the marketplace offer. Required. :vartype publisher_id: str :ivar offer_id: Offer Id for the marketplace offer. Required. @@ -209,17 +970,17 @@ class OfferDetails(_model_base.Model): :vartype term_id: str """ - publisher_id: str = rest_field(name="publisherId") + publisher_id: str = rest_field(name="publisherId", visibility=["read", "create", "update", "delete", "query"]) """Publisher Id for the marketplace offer. Required.""" - offer_id: str = rest_field(name="offerId") + offer_id: str = rest_field(name="offerId", visibility=["read", "create", "update", "delete", "query"]) """Offer Id for the marketplace offer. Required.""" - plan_id: str = rest_field(name="planId") + plan_id: str = rest_field(name="planId", visibility=["read", "create", "update", "delete", "query"]) """Plan Id for the marketplace offer. Required.""" - plan_name: Optional[str] = rest_field(name="planName") + plan_name: Optional[str] = rest_field(name="planName", visibility=["read", "create", "update", "delete", "query"]) """Plan Name for the marketplace offer.""" - term_unit: Optional[str] = rest_field(name="termUnit") + term_unit: Optional[str] = rest_field(name="termUnit", visibility=["read", "create", "update", "delete", "query"]) """Term Name for the marketplace offer.""" - term_id: Optional[str] = rest_field(name="termId") + term_id: Optional[str] = rest_field(name="termId", visibility=["read", "create", "update", "delete", "query"]) """Term Id for the marketplace offer.""" @overload @@ -248,8 +1009,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class Operation(_model_base.Model): """Details of a REST API operation, returned from the Resource Provider Operations API. - Readonly variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". :vartype name: str @@ -274,13 +1033,15 @@ class Operation(_model_base.Model): is_data_action: Optional[bool] = rest_field(name="isDataAction", visibility=["read"]) """Whether the operation applies to data-plane. This is \"true\" for data-plane operations and \"false\" for Azure Resource Manager/control-plane operations.""" - display: Optional["_models.OperationDisplay"] = rest_field(visibility=["read"]) + display: Optional["_models.OperationDisplay"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """Localized display information for this particular operation.""" origin: Optional[Union[str, "_models.Origin"]] = rest_field(visibility=["read"]) """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is \"user,system\". Known values are: \"user\", \"system\", and \"user,system\".""" - action_type: Optional[Union[str, "_models.ActionType"]] = rest_field(name="actionType") + action_type: Optional[Union[str, "_models.ActionType"]] = rest_field(name="actionType", visibility=["read"]) """Extensible enum. Indicates the action type. \"Internal\" refers to actions that are for internal only APIs. \"Internal\"""" @@ -288,7 +1049,7 @@ class Operation(_model_base.Model): def __init__( self, *, - action_type: Optional[Union[str, "_models.ActionType"]] = None, + display: Optional["_models.OperationDisplay"] = None, ) -> None: ... @overload @@ -305,8 +1066,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class OperationDisplay(_model_base.Model): """Localized display information for and operation. - Readonly variables are only populated by the server, and will be ignored when sending a request. - :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". :vartype provider: str @@ -336,10 +1095,7 @@ class OperationDisplay(_model_base.Model): class OrganizationProperties(_model_base.Model): - """Properties specific to Data Organization resource. - - Readonly variables are only populated by the server, and will be ignored when sending a request. - + """Properties specific to Neon Organization resource. :ivar marketplace_details: Marketplace details of the resource. Required. :vartype marketplace_details: ~azure.mgmt.neonpostgres.models.MarketplaceDetails @@ -350,18 +1106,24 @@ class OrganizationProperties(_model_base.Model): :ivar provisioning_state: Provisioning state of the resource. Known values are: "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.neonpostgres.models.ResourceProvisioningState - :ivar partner_organization_properties: Organization properties. + :ivar partner_organization_properties: Neon Organization properties. :vartype partner_organization_properties: ~azure.mgmt.neonpostgres.models.PartnerOrganizationProperties + :ivar project_properties: Neon Project Properties. + :vartype project_properties: ~azure.mgmt.neonpostgres.models.ProjectProperties """ 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(name="userDetails") + user_details: "_models.UserDetails" = rest_field( + name="userDetails", visibility=["read", "create", "update", "delete", "query"] + ) """Details of the user. Required.""" - company_details: "_models.CompanyDetails" = rest_field(name="companyDetails") + company_details: "_models.CompanyDetails" = rest_field( + name="companyDetails", visibility=["read", "create", "update", "delete", "query"] + ) """Details of the company. Required.""" provisioning_state: Optional[Union[str, "_models.ResourceProvisioningState"]] = rest_field( name="provisioningState", visibility=["read"] @@ -369,9 +1131,13 @@ class OrganizationProperties(_model_base.Model): """Provisioning state of the resource. Known values are: \"Succeeded\", \"Failed\", and \"Canceled\".""" partner_organization_properties: Optional["_models.PartnerOrganizationProperties"] = rest_field( - name="partnerOrganizationProperties" + name="partnerOrganizationProperties", visibility=["read", "create", "update", "delete", "query"] + ) + """Neon Organization properties.""" + project_properties: Optional["_models.ProjectProperties"] = rest_field( + name="projectProperties", visibility=["read", "create", "update", "delete", "query"] ) - """Organization properties.""" + """Neon Project Properties.""" @overload def __init__( @@ -381,6 +1147,7 @@ def __init__( user_details: "_models.UserDetails", company_details: "_models.CompanyDetails", partner_organization_properties: Optional["_models.PartnerOrganizationProperties"] = None, + project_properties: Optional["_models.ProjectProperties"] = None, ) -> None: ... @overload @@ -394,45 +1161,12 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class Resource(_model_base.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Readonly variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.neonpostgres.models.SystemData - """ - - id: Optional[str] = rest_field(visibility=["read"]) - """Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long""" - name: Optional[str] = rest_field(visibility=["read"]) - """The name of the resource.""" - type: Optional[str] = rest_field(visibility=["read"]) - """The type of the resource. E.g. \"Microsoft.Compute/virtualMachines\" or - \"Microsoft.Storage/storageAccounts\".""" - system_data: Optional["_models.SystemData"] = rest_field(name="systemData", visibility=["read"]) - """Azure Resource Manager metadata containing createdBy and modifiedBy information.""" - - class TrackedResource(Resource): """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. - Readonly variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -448,7 +1182,7 @@ class TrackedResource(Resource): :vartype location: str """ - tags: Optional[Dict[str, str]] = rest_field() + tags: Optional[Dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Resource tags.""" location: str = rest_field(visibility=["read", "create"]) """The geo-location where the resource lives. Required.""" @@ -475,11 +1209,8 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class OrganizationResource(TrackedResource): """Organization Resource by Neon. - Readonly variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -497,7 +1228,9 @@ class OrganizationResource(TrackedResource): :vartype properties: ~azure.mgmt.neonpostgres.models.OrganizationProperties """ - properties: Optional["_models.OrganizationProperties"] = rest_field() + properties: Optional["_models.OrganizationProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The resource-specific properties for this resource.""" @overload @@ -523,7 +1256,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class PartnerOrganizationProperties(_model_base.Model): """Properties specific to Partner's organization. - :ivar organization_id: Organization Id in partner's system. :vartype organization_id: str :ivar organization_name: Organization name in partner's system. Required. @@ -532,11 +1264,17 @@ class PartnerOrganizationProperties(_model_base.Model): :vartype single_sign_on_properties: ~azure.mgmt.neonpostgres.models.SingleSignOnProperties """ - organization_id: Optional[str] = rest_field(name="organizationId") + organization_id: Optional[str] = rest_field( + name="organizationId", visibility=["read", "create", "update", "delete", "query"] + ) """Organization Id in partner's system.""" - organization_name: str = rest_field(name="organizationName") + organization_name: str = rest_field( + name="organizationName", visibility=["read", "create", "update", "delete", "query"] + ) """Organization name in partner's system. Required.""" - single_sign_on_properties: Optional["_models.SingleSignOnProperties"] = rest_field(name="singleSignOnProperties") + single_sign_on_properties: Optional["_models.SingleSignOnProperties"] = rest_field( + name="singleSignOnProperties", visibility=["read", "create", "update", "delete", "query"] + ) """Single Sign On properties for the organization.""" @overload @@ -559,6 +1297,213 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) +class PgVersion(_model_base.Model): + """PostgreSQL Version model. + + :ivar version: The major PostgreSQL version number. + :vartype version: int + """ + + version: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The major PostgreSQL version number.""" + + @overload + def __init__( + self, + *, + version: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PgVersionsResult(_model_base.Model): + """Response model for PostgreSQL versions. + + :ivar versions: List of PostgreSQL versions. Required. + :vartype versions: list[~azure.mgmt.neonpostgres.models.PgVersion] + """ + + versions: List["_models.PgVersion"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """List of PostgreSQL versions. Required.""" + + @overload + def __init__( + self, + *, + versions: List["_models.PgVersion"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Project(ProxyResource): + """The Project resource type. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.neonpostgres.models.SystemData + :ivar properties: The resource-specific properties for this resource. + :vartype properties: ~azure.mgmt.neonpostgres.models.ProjectProperties + """ + + properties: Optional["_models.ProjectProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The resource-specific properties for this resource.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.ProjectProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ProjectProperties(_model_base.Model): + """Properties specific to Project. + + :ivar entity_id: Unique identifier for the entity. + :vartype entity_id: str + :ivar entity_name: Name of the resource. + :vartype entity_name: str + :ivar created_at: Timestamp indicating when the entity was created. + :vartype created_at: str + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Succeeded", + "Failed", and "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.neonpostgres.models.ResourceProvisioningState + :ivar attributes: Additional attributes for the entity. + :vartype attributes: list[~azure.mgmt.neonpostgres.models.Attributes] + :ivar region_id: Region where the project is created. + :vartype region_id: str + :ivar storage: Data Storage bytes per hour for the project. + :vartype storage: int + :ivar pg_version: Postgres version for the project. + :vartype pg_version: int + :ivar history_retention: The retention period for project history in seconds. + :vartype history_retention: int + :ivar default_endpoint_settings: Default endpoint settings for the project. + :vartype default_endpoint_settings: ~azure.mgmt.neonpostgres.models.DefaultEndpointSettings + :ivar branch: The Branch properties of the project. This is optional. + :vartype branch: ~azure.mgmt.neonpostgres.models.BranchProperties + :ivar roles: Roles associated with the project. + :vartype roles: list[~azure.mgmt.neonpostgres.models.NeonRoleProperties] + :ivar databases: Neon Databases associated with the project. + :vartype databases: list[~azure.mgmt.neonpostgres.models.NeonDatabaseProperties] + :ivar endpoints: Endpoints associated with the project. + :vartype endpoints: list[~azure.mgmt.neonpostgres.models.EndpointProperties] + """ + + entity_id: Optional[str] = rest_field(name="entityId", visibility=["read"]) + """Unique identifier for the entity.""" + entity_name: Optional[str] = rest_field( + name="entityName", visibility=["read", "create", "update", "delete", "query"] + ) + """Name of the resource.""" + created_at: Optional[str] = rest_field(name="createdAt", visibility=["read"]) + """Timestamp indicating when the entity was created.""" + provisioning_state: Optional[Union[str, "_models.ResourceProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state of the resource. Known values are: \"Succeeded\", \"Failed\", and + \"Canceled\".""" + attributes: Optional[List["_models.Attributes"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Additional attributes for the entity.""" + region_id: Optional[str] = rest_field(name="regionId", visibility=["read", "create", "update", "delete", "query"]) + """Region where the project is created.""" + storage: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Data Storage bytes per hour for the project.""" + pg_version: Optional[int] = rest_field(name="pgVersion", visibility=["read", "create", "update", "delete", "query"]) + """Postgres version for the project.""" + history_retention: Optional[int] = rest_field( + name="historyRetention", visibility=["read", "create", "update", "delete", "query"] + ) + """The retention period for project history in seconds.""" + default_endpoint_settings: Optional["_models.DefaultEndpointSettings"] = rest_field( + name="defaultEndpointSettings", visibility=["read", "create", "update", "delete", "query"] + ) + """Default endpoint settings for the project.""" + branch: Optional["_models.BranchProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The Branch properties of the project. This is optional.""" + roles: Optional[List["_models.NeonRoleProperties"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Roles associated with the project.""" + databases: Optional[List["_models.NeonDatabaseProperties"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Neon Databases associated with the project.""" + endpoints: Optional[List["_models.EndpointProperties"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Endpoints associated with the project.""" + + @overload + def __init__( + self, + *, + entity_name: Optional[str] = None, + attributes: Optional[List["_models.Attributes"]] = None, + region_id: Optional[str] = None, + storage: Optional[int] = None, + pg_version: Optional[int] = None, + history_retention: Optional[int] = None, + default_endpoint_settings: Optional["_models.DefaultEndpointSettings"] = None, + branch: Optional["_models.BranchProperties"] = None, + roles: Optional[List["_models.NeonRoleProperties"]] = None, + databases: Optional[List["_models.NeonDatabaseProperties"]] = None, + endpoints: Optional[List["_models.EndpointProperties"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + class SingleSignOnProperties(_model_base.Model): """Properties specific to Single Sign On Resource. @@ -574,14 +1519,22 @@ class SingleSignOnProperties(_model_base.Model): :vartype aad_domains: list[str] """ - single_sign_on_state: Optional[Union[str, "_models.SingleSignOnStates"]] = rest_field(name="singleSignOnState") + single_sign_on_state: Optional[Union[str, "_models.SingleSignOnStates"]] = rest_field( + name="singleSignOnState", visibility=["read", "create", "update", "delete", "query"] + ) """State of the Single Sign On for the organization. Known values are: \"Initial\", \"Enable\", and \"Disable\".""" - enterprise_app_id: Optional[str] = rest_field(name="enterpriseAppId") + enterprise_app_id: Optional[str] = rest_field( + name="enterpriseAppId", visibility=["read", "create", "update", "delete", "query"] + ) """AAD enterprise application Id used to setup SSO.""" - single_sign_on_url: Optional[str] = rest_field(name="singleSignOnUrl") + single_sign_on_url: Optional[str] = rest_field( + name="singleSignOnUrl", visibility=["read", "create", "update", "delete", "query"] + ) """URL for SSO to be used by the partner to redirect the user to their system.""" - aad_domains: Optional[List[str]] = rest_field(name="aadDomains") + aad_domains: Optional[List[str]] = rest_field( + name="aadDomains", visibility=["read", "create", "update", "delete", "query"] + ) """List of AAD domains fetched from Microsoft Graph for user.""" @overload @@ -624,19 +1577,29 @@ class SystemData(_model_base.Model): :vartype last_modified_at: ~datetime.datetime """ - created_by: Optional[str] = rest_field(name="createdBy") + created_by: Optional[str] = rest_field(name="createdBy", visibility=["read", "create", "update", "delete", "query"]) """The identity that created the resource.""" - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field(name="createdByType") + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="createdByType", visibility=["read", "create", "update", "delete", "query"] + ) """The type of identity that created the resource. Known values are: \"User\", \"Application\", \"ManagedIdentity\", and \"Key\".""" - created_at: Optional[datetime.datetime] = rest_field(name="createdAt", format="rfc3339") + created_at: Optional[datetime.datetime] = rest_field( + name="createdAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) """The timestamp of resource creation (UTC).""" - last_modified_by: Optional[str] = rest_field(name="lastModifiedBy") + last_modified_by: Optional[str] = rest_field( + name="lastModifiedBy", visibility=["read", "create", "update", "delete", "query"] + ) """The identity that last modified the resource.""" - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field(name="lastModifiedByType") + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="lastModifiedByType", visibility=["read", "create", "update", "delete", "query"] + ) """The type of identity that last modified the resource. Known values are: \"User\", \"Application\", \"ManagedIdentity\", and \"Key\".""" - last_modified_at: Optional[datetime.datetime] = rest_field(name="lastModifiedAt", format="rfc3339") + last_modified_at: Optional[datetime.datetime] = rest_field( + name="lastModifiedAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) """The timestamp of resource last modification (UTC).""" @overload @@ -677,15 +1640,19 @@ class UserDetails(_model_base.Model): :vartype phone_number: str """ - first_name: Optional[str] = rest_field(name="firstName") + first_name: Optional[str] = rest_field(name="firstName", visibility=["read", "create", "update", "delete", "query"]) """First name of the user.""" - last_name: Optional[str] = rest_field(name="lastName") + last_name: Optional[str] = rest_field(name="lastName", visibility=["read", "create", "update", "delete", "query"]) """Last name of the user.""" - email_address: Optional[str] = rest_field(name="emailAddress") + email_address: Optional[str] = rest_field( + name="emailAddress", visibility=["read", "create", "update", "delete", "query"] + ) """Email address of the user.""" - upn: Optional[str] = rest_field() + upn: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """User's principal name.""" - phone_number: Optional[str] = rest_field(name="phoneNumber") + phone_number: Optional[str] = rest_field( + name="phoneNumber", visibility=["read", "create", "update", "delete", "query"] + ) """User's phone number.""" @overload diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/models/_patch.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/models/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/models/_patch.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/models/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize 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 72e76f8318ab..2828a5d7896d 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,16 +12,30 @@ 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 +from ._operations import BranchesOperations # type: ignore +from ._operations import ComputesOperations # type: ignore +from ._operations import NeonDatabasesOperations # type: ignore +from ._operations import NeonRolesOperations # type: ignore +from ._operations import EndpointsOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ + "ModelsOperations", "Operations", "OrganizationsOperations", + "ProjectsOperations", + "BranchesOperations", + "ComputesOperations", + "NeonDatabasesOperations", + "NeonRolesOperations", + "EndpointsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() 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 a63af8bdb887..f0b305ce4e54 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -12,6 +12,7 @@ from typing import Any, Callable, Dict, IO, Iterable, Iterator, List, Optional, TypeVar, Union, cast, overload import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -32,8 +33,10 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._model_base import SdkJSONEncoder, _deserialize -from .._serialization import Serializer +from .._configuration import NeonPostgresMgmtClientConfiguration +from .._model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize +from .._serialization import Deserializer, Serializer +from .._validation import api_version_validation if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -51,7 +54,7 @@ def build_operations_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,11 +75,11 @@ def build_organizations_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-08-01-preview")) + 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}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -101,11 +104,11 @@ def build_organizations_create_or_update_request( # pylint: disable=name-too-lo _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", "2024-08-01-preview")) + 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}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -132,11 +135,11 @@ def build_organizations_update_request( _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", "2024-08-01-preview")) + 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}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -162,11 +165,11 @@ def build_organizations_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-08-01-preview")) + 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}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -190,7 +193,7 @@ def build_organizations_list_by_resource_group_request( # pylint: disable=name- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -217,7 +220,7 @@ def build_organizations_list_by_subscription_request( # pylint: disable=name-to _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -237,35 +240,6875 @@ def build_organizations_list_by_subscription_request( # pylint: disable=name-to return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) +def build_organizations_get_postgres_versions_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + 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/getPostgresVersions" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_projects_get_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 {}) + + 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 + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_projects_create_or_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="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: + _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}" + 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 + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_projects_list_request( + resource_group_name: str, organization_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" + 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"), + } + + _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_projects_get_connection_uri_request( # pylint: disable=name-too-long + 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}/getConnectionUri" + 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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_branches_get_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}" + 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_branches_create_or_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="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, + 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}" + 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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_branches_list_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 {}) + + 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" + 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 + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_computes_get_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 {}) + + 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}" + 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 + + # 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_computes_create_or_update_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}" + 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 + + # 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_computes_update_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}" + 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 + + # 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_computes_delete_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 {}) + + 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}" + 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 + + # 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_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") + + # 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"), + } + + _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_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 {}) + + 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="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +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 {}) + + 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="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. - """ + 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. + """ + + 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_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. + + :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 = 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.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", + ] + }, + ) + 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 + ) -> 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_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 = 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, + neon_database_name: str, + resource: _models.NeonDatabase, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_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 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: + """ + + @overload + 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. + + :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] + :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_database_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_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 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", + ] + }, + ) + 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 + ) -> LROPoller[_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 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: + """ + _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, 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_database_name=neon_database_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.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: 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.NeonDatabase].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_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", + ] + }, + ) + 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 + ) -> 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_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 = 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, + neon_database_name: str, + properties: _models.NeonDatabase, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_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 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: + """ + + @overload + 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. + + :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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + 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. + + :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", + ] + }, + ) + 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 + ) -> LROPoller[_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 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: + """ + _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, 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, + neon_database_name=neon_database_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.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: 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.NeonDatabase].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.NeonDatabase]( + 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: + """ + 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 = 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.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.paging.ItemPaged[~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 + + 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, 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 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( + 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 = 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.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", + ] + }, + ) + 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 + ) -> 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_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 = 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, + neon_role_name: str, + resource: _models.NeonRole, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_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 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: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_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 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. + + :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: + """ + + @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", + ] + }, + ) + 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. + + :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 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: + """ + _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, 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) + + 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: 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 + ) + + @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", + ] + }, + ) + 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 + ) -> 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 {} - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + 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_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 = 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, + neon_role_name: str, + properties: _models.NeonRole, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_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 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_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 + ) -> LROPoller[_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 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_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 + ) -> LROPoller[_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 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: + """ @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: - """List the operations for the provider. + @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", + ] + }, + ) + 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 + ) -> LROPoller[_models.NeonRole]: + """Update a NeonRole. - :return: An iterator like instance of Operation - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.neonpostgres.models.Operation] + :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 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: + """ + _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, 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, + neon_role_name=neon_role_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.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: 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 + ) + + @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 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 + ) -> 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[List[_models.Operation]] = kwargs.pop("cls", None) + 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 = 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.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.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, @@ -278,7 +7121,12 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - _request = build_operations_list_request( + _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, @@ -314,7 +7162,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Operation], deserialized["value"]) + 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) @@ -330,7 +7178,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -338,34 +7186,63 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) -class OrganizationsOperations: +class EndpointsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.neonpostgres.NeonPostgresMgmtClient`'s - :attr:`organizations` attribute. + :attr:`endpoints` attribute. """ def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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. + @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", + ] + }, + ) + 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 - :return: OrganizationResource. The OrganizationResource is compatible with MutableMapping - :rtype: ~azure.mgmt.neonpostgres.models.OrganizationResource + :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 = { @@ -379,11 +7256,14 @@ def get(self, resource_group_name: str, organization_name: str, **kwargs: Any) - _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.OrganizationResource] = kwargs.pop("cls", None) + cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) - _request = build_organizations_get_request( + _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, @@ -408,24 +7288,43 @@ def get(self, resource_group_name: str, organization_name: str, **kwargs: Any) - except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + 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()) + 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", + ] + }, + ) def _create_or_update_initial( self, resource_group_name: str, organization_name: str, - resource: Union[_models.OrganizationResource, JSON, IO[bytes]], + project_name: str, + branch_name: str, + endpoint_name: str, + resource: Union[_models.Endpoint, JSON, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -449,9 +7348,12 @@ def _create_or_update_initial( else: _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_organizations_create_or_update_request( + _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, @@ -477,7 +7379,7 @@ def _create_or_update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -499,26 +7401,35 @@ def begin_create_or_update( self, resource_group_name: str, organization_name: str, - resource: _models.OrganizationResource, + project_name: str, + branch_name: str, + endpoint_name: str, + resource: _models.Endpoint, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.OrganizationResource]: - """Create a OrganizationResource. + ) -> LROPoller[_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.OrganizationResource + :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 LROPoller that returns OrganizationResource. The OrganizationResource - is compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.OrganizationResource] + :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: """ @@ -527,26 +7438,35 @@ 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 - ) -> LROPoller[_models.OrganizationResource]: - """Create a OrganizationResource. + ) -> LROPoller[_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 LROPoller that returns OrganizationResource. The OrganizationResource - is compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.OrganizationResource] + :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: """ @@ -555,57 +7475,91 @@ 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 - ) -> LROPoller[_models.OrganizationResource]: - """Create a OrganizationResource. + ) -> LROPoller[_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 LROPoller that returns OrganizationResource. The OrganizationResource - is compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.OrganizationResource] + :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: """ @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", + "endpoint_name", + "content_type", + "accept", + ] + }, + ) def begin_create_or_update( self, resource_group_name: str, organization_name: str, - resource: Union[_models.OrganizationResource, JSON, IO[bytes]], + project_name: str, + branch_name: str, + endpoint_name: str, + resource: Union[_models.Endpoint, JSON, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.OrganizationResource]: - """Create a OrganizationResource. + ) -> LROPoller[_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 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] + :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 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: """ _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) + 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) @@ -613,6 +7567,9 @@ 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, + endpoint_name=endpoint_name, resource=resource, content_type=content_type, cls=lambda x, y, z: x, @@ -625,7 +7582,7 @@ def begin_create_or_update( def get_long_running_output(pipeline_response): response = pipeline_response.http_response - deserialized = _deserialize(_models.OrganizationResource, response.json()) + deserialized = _deserialize(_models.Endpoint, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -643,21 +7600,40 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.OrganizationResource].from_continuation_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, ) - return LROPoller[_models.OrganizationResource]( + return LROPoller[_models.Endpoint]( 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", + "endpoint_name", + "content_type", + "accept", + ] + }, + ) def _update_initial( self, resource_group_name: str, organization_name: str, - properties: Union[_models.OrganizationResource, JSON, IO[bytes]], + project_name: str, + branch_name: str, + endpoint_name: str, + properties: Union[_models.Endpoint, JSON, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -681,9 +7657,12 @@ def _update_initial( else: _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_organizations_update_request( + _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, @@ -709,7 +7688,7 @@ def _update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -729,26 +7708,35 @@ def begin_update( self, resource_group_name: str, organization_name: str, - properties: _models.OrganizationResource, + project_name: str, + branch_name: str, + endpoint_name: str, + properties: _models.Endpoint, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.OrganizationResource]: - """Update a OrganizationResource. + ) -> 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: ~azure.mgmt.neonpostgres.models.OrganizationResource + :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 OrganizationResource. The OrganizationResource - is compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.OrganizationResource] + :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: """ @@ -757,26 +7745,35 @@ 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.OrganizationResource]: - """Update a OrganizationResource. + ) -> 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 OrganizationResource. The OrganizationResource - is compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.neonpostgres.models.OrganizationResource] + :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: """ @@ -785,57 +7782,91 @@ 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.OrganizationResource]: - """Update a OrganizationResource. + ) -> 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: 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] + :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: """ @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", + "endpoint_name", + "content_type", + "accept", + ] + }, + ) def begin_update( self, resource_group_name: str, organization_name: str, - properties: Union[_models.OrganizationResource, JSON, IO[bytes]], + project_name: str, + branch_name: str, + endpoint_name: str, + properties: Union[_models.Endpoint, JSON, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.OrganizationResource]: - """Update a OrganizationResource. + ) -> 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. 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] + 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] :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) + 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) @@ -843,6 +7874,9 @@ 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, + endpoint_name=endpoint_name, properties=properties, content_type=content_type, cls=lambda x, y, z: x, @@ -855,7 +7889,7 @@ def begin_update( def get_long_running_output(pipeline_response): response = pipeline_response.http_response - deserialized = _deserialize(_models.OrganizationResource, response.json()) + deserialized = _deserialize(_models.Endpoint, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -873,17 +7907,58 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.OrganizationResource].from_continuation_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, ) - return LROPoller[_models.OrganizationResource]( + return LROPoller[_models.Endpoint]( 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]: + @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", + "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. + + :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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -895,11 +7970,14 @@ def _delete_initial(self, resource_group_name: str, organization_name: str, **kw _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_organizations_delete_request( + _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, @@ -910,108 +7988,58 @@ def _delete_initial(self, resource_group_name: str, organization_name: str, **kw } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = True + _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 [202, 204]: - try: - 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 = _deserialize(_models.ErrorResponse, response.json()) + 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 + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def begin_delete(self, resource_group_name: str, organization_name: str, **kwargs: Any) -> LROPoller[None]: - """Delete a OrganizationResource. + @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.Endpoint"]: + """List Endpoint 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 - :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] + :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 Endpoint + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.neonpostgres.models.Endpoint] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.OrganizationResource]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.Endpoint]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1024,8 +8052,11 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - _request = build_organizations_list_by_resource_group_request( + _request = build_endpoints_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, @@ -1062,91 +8093,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.OrganizationResource], deserialized["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 = _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["value"]) + list_of_elem = _deserialize(List[_models.Endpoint], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -1162,7 +8109,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/operations/_patch.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/operations/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/operations/_patch.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/operations/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize 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 new file mode 100644 index 000000000000..e883b62b7bfd --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/branches_create_or_update_maximum_set_gen.py @@ -0,0 +1,80 @@ +# 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_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.branches.begin_create_or_update( + resource_group_name="rgneon", + organization_name="test-org", + project_name="test-entity", + branch_name="test-entity", + resource={ + "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_CreateOrUpdate_MaximumSet_Gen.json +if __name__ == "__main__": + main() 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 new file mode 100644 index 000000000000..8c6726fbd18e --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/branches_delete_maximum_set_gen.py @@ -0,0 +1,43 @@ +# 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_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.branches.delete( + resource_group_name="rgneon", + organization_name="test-org", + project_name="entity-name", + branch_name="entity-name", + ) + + +# x-ms-original-file: 2025-03-01/Branches_Delete_MaximumSet_Gen.json +if __name__ == "__main__": + main() 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 new file mode 100644 index 000000000000..d2d1fcc370df --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/branches_get_maximum_set_gen.py @@ -0,0 +1,44 @@ +# 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_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.branches.get( + resource_group_name="rgneon", + organization_name="test-org", + project_name="entity-name", + branch_name="entity-name", + ) + print(response) + + +# x-ms-original-file: 2025-03-01/Branches_Get_MaximumSet_Gen.json +if __name__ == "__main__": + main() 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 new file mode 100644 index 000000000000..de202ec70c69 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/branches_list_maximum_set_gen.py @@ -0,0 +1,44 @@ +# 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_list_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.list( + resource_group_name="rgneon", + organization_name="test-org", + project_name="entity-name", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2025-03-01/Branches_List_MaximumSet_Gen.json +if __name__ == "__main__": + main() 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 new file mode 100644 index 000000000000..b227f4a49c23 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/branches_update_maximum_set_gen.py @@ -0,0 +1,80 @@ +# 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 new file mode 100644 index 000000000000..2829f960777b --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/computes_create_or_update_maximum_set_gen.py @@ -0,0 +1,55 @@ +# 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_delete_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/computes_delete_maximum_set_gen.py new file mode 100644 index 000000000000..e6bc1653c53e --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/computes_delete_maximum_set_gen.py @@ -0,0 +1,44 @@ +# 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_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.computes.delete( + resource_group_name="rgneon", + organization_name="test-org", + project_name="entity-name", + branch_name="entity-name", + compute_name="entity-name", + ) + + +# x-ms-original-file: 2025-03-01/Computes_Delete_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 new file mode 100644 index 000000000000..c50ded1e4236 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/computes_get_maximum_set_gen.py @@ -0,0 +1,45 @@ +# 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 new file mode 100644 index 000000000000..fedfff098c50 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/computes_list_maximum_set_gen.py @@ -0,0 +1,45 @@ +# 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_list_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.list( + resource_group_name="rgneon", + organization_name="test-org", + project_name="entity-name", + branch_name="entity-name", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2025-03-01/Computes_List_MaximumSet_Gen.json +if __name__ == "__main__": + main() 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 new file mode 100644 index 000000000000..7b961bbf39c0 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/computes_update_maximum_set_gen.py @@ -0,0 +1,55 @@ +# 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 new file mode 100644 index 000000000000..ae51158bef95 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/endpoints_create_or_update_maximum_set_gen.py @@ -0,0 +1,54 @@ +# 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_delete_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/endpoints_delete_maximum_set_gen.py new file mode 100644 index 000000000000..45ecff88f4be --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/endpoints_delete_maximum_set_gen.py @@ -0,0 +1,44 @@ +# 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_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.endpoints.delete( + resource_group_name="rgneon", + organization_name="test-org", + project_name="entity-name", + branch_name="entity-name", + endpoint_name="entity-name", + ) + + +# x-ms-original-file: 2025-03-01/Endpoints_Delete_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 new file mode 100644 index 000000000000..83d2a39c3604 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/endpoints_get_maximum_set_gen.py @@ -0,0 +1,45 @@ +# 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 new file mode 100644 index 000000000000..beb5b5d810b5 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/endpoints_list_maximum_set_gen.py @@ -0,0 +1,45 @@ +# 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_list_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.list( + resource_group_name="rgneon", + organization_name="test-org", + project_name="entity-name", + branch_name="entity-name", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2025-03-01/Endpoints_List_MaximumSet_Gen.json +if __name__ == "__main__": + main() 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 new file mode 100644 index 000000000000..e4a6f5d21be8 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/endpoints_update_maximum_set_gen.py @@ -0,0 +1,54 @@ +# 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 new file mode 100644 index 000000000000..db5286fa1eb2 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_databases_create_or_update_maximum_set_gen.py @@ -0,0 +1,53 @@ +# 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 new file mode 100644 index 000000000000..ccaacdf27c03 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_databases_delete_maximum_set_gen.py @@ -0,0 +1,44 @@ +# 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 new file mode 100644 index 000000000000..6624eafd84c7 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_databases_get_maximum_set_gen.py @@ -0,0 +1,45 @@ +# 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 new file mode 100644 index 000000000000..c0d12be768a9 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_databases_list_maximum_set_gen.py @@ -0,0 +1,45 @@ +# 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_list_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.list( + resource_group_name="rgneon", + organization_name="test-org", + project_name="entity-name", + branch_name="entity-name", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2025-03-01/NeonDatabases_List_MaximumSet_Gen.json +if __name__ == "__main__": + main() 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 new file mode 100644 index 000000000000..d49b096e3f77 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_databases_update_maximum_set_gen.py @@ -0,0 +1,53 @@ +# 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 new file mode 100644 index 000000000000..0e5c4a9fc595 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_roles_create_or_update_maximum_set_gen.py @@ -0,0 +1,54 @@ +# 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 new file mode 100644 index 000000000000..ad9481c8c243 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_roles_delete_maximum_set_gen.py @@ -0,0 +1,44 @@ +# 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 new file mode 100644 index 000000000000..a45b7b24d2b2 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_roles_get_maximum_set_gen.py @@ -0,0 +1,45 @@ +# 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 new file mode 100644 index 000000000000..758d8e3f2fbf --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_roles_list_maximum_set_gen.py @@ -0,0 +1,45 @@ +# 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_list_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.list( + resource_group_name="rgneon", + organization_name="test-org", + project_name="entity-name", + branch_name="entity-name", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2025-03-01/NeonRoles_List_MaximumSet_Gen.json +if __name__ == "__main__": + main() 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 new file mode 100644 index 000000000000..44b91e874bd8 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/neon_roles_update_maximum_set_gen.py @@ -0,0 +1,54 @@ +# 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/operations_list_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/operations_list_maximum_set_gen.py index 1592ff526739..70e99c278df8 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/operations_list_maximum_set_gen.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/operations_list_maximum_set_gen.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: 2024-08-01-preview/Operations_List_MaximumSet_Gen.json +# x-ms-original-file: 2025-03-01/Operations_List_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/operations_list_minimum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/operations_list_minimum_set_gen.py new file mode 100644 index 000000000000..f7ed48eb2655 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/operations_list_minimum_set_gen.py @@ -0,0 +1,40 @@ +# 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 operations_list_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, + 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.operations.list() + for item in response: + print(item) + + +# x-ms-original-file: 2025-03-01/Operations_List_MinimumSet_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 87696c63d9a8..e8af1709f1bb 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,54 +32,123 @@ def main(): response = client.organizations.begin_create_or_update( resource_group_name="rgneon", - organization_name="XB-.:", + organization_name="test-org", resource={ - "location": "upxxgikyqrbnv", + "location": "kcdph", "properties": { "companyDetails": { - "businessPhone": "hbeb", - "companyName": "uxn", - "country": "lpajqzptqchuko", - "domain": "krjldeakhwiepvs", - "numberOfEmployees": 23, - "officeAddress": "chpkrlpmfslmawgunjxdllzcrctykq", + "businessPhone": "hucxvzcvpaupqjkgb", + "companyName": "xtul", + "country": "ycmyjdcpyjieemfrthfyxdlvn", + "domain": "snoshqumfsthyofpnrsgyjhszvgtj", + "numberOfEmployees": 12, + "officeAddress": "icirtoqmmozijk", }, "marketplaceDetails": { "offerDetails": { - "offerId": "bunyeeupoedueofwrzej", - "planId": "nlbfiwtslenfwek", - "planName": "ljbmgpkfqklaufacbpml", - "publisherId": "hporaxnopmolttlnkbarw", - "termId": "aedlchikwqckuploswthvshe", - "termUnit": "qbcq", + "offerId": "qscggwfdnippiwrrnmuscg", + "planId": "sveqoxtdwxutxmtniuufyrdu", + "planName": "t", + "publisherId": "eibghzuyqsksouwlgqphhmuxeqeigf", + "termId": "uptombvymytfonj", + "termUnit": "jnxhyql", }, - "subscriptionId": "yxmkfivp", + "subscriptionId": "xfahbbbzwlcwhhjbxarnwfcy", "subscriptionStatus": "PendingFulfillmentStart", }, "partnerOrganizationProperties": { - "organizationId": "nrhvoqzulowcunhmvwfgjcaibvwcl", - "organizationName": "2__.-", + "organizationId": "hzejhmftwsruhwspvtwoy", + "organizationName": "entity-name", "singleSignOnProperties": { - "aadDomains": ["kndszgrwzbvvlssvkej"], - "enterpriseAppId": "fpibacregjfncfdsojs", + "aadDomains": ["mdzbelaiphukhe"], + "enterpriseAppId": "urtjzjfr", "singleSignOnState": "Initial", - "singleSignOnUrl": "tmojh", + "singleSignOnUrl": "gcmlwvtxcsjozitm", }, }, + "projectProperties": { + "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": 20, "autoscalingLimitMinCu": 26}, + "endpoints": [ + { + "attributes": [{"name": "trhvzyvaqy", "value": "evpkgsskyavybxwwssm"}], + "branchId": "rzsyrhpfbydxtfkpaa", + "endpointType": "read_only", + "entityName": "entity-name", + "projectId": "rtvdeeflqzlrpfzhjqhcsfbldw", + } + ], + "entityName": "entity-name", + "historyRetention": 7, + "pgVersion": 10, + "regionId": "tlcltldfrnxh", + "roles": [ + { + "attributes": [{"name": "trhvzyvaqy", "value": "evpkgsskyavybxwwssm"}], + "branchId": "wxbojkmdgaggkfiwqfakdkbyztm", + "entityName": "entity-name", + "isSuperUser": True, + "permissions": ["myucqecpjriewzohxvadgkhiudnyx"], + } + ], + "storage": 7, + }, "userDetails": { - "emailAddress": "3i_%@w8-y.H-p.tvj.dG", - "firstName": "buwwe", - "lastName": "escynjpynkoox", - "phoneNumber": "dlrqoowumy", - "upn": "fwedjamgwwrotcjaucuzdwycfjdqn", + "emailAddress": "test@contoso.com", + "firstName": "zhelh", + "lastName": "zbdhouyeozylnerrc", + "phoneNumber": "zmejenytglrmjnt", + "upn": "mixcikvxlnhkfugetqlngz", }, }, - "tags": {"key2099": "omjjymaqtrqzksxszhzgyl"}, + "tags": {"key8832": "rvukepuxkykdtqjtwk"}, }, ).result() print(response) -# x-ms-original-file: 2024-08-01-preview/Organizations_CreateOrUpdate_MaximumSet_Gen.json +# x-ms-original-file: 2025-03-01/Organizations_CreateOrUpdate_MaximumSet_Gen.json if __name__ == "__main__": main() 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 5ddf5321b0c9..5c0595324dae 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,10 +32,10 @@ def main(): client.organizations.begin_delete( resource_group_name="rgneon", - organization_name="2_3", + organization_name="test-org", ).result() -# x-ms-original-file: 2024-08-01-preview/Organizations_Delete_MaximumSet_Gen.json +# x-ms-original-file: 2025-03-01/Organizations_Delete_MaximumSet_Gen.json if __name__ == "__main__": main() 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 f29802340d16..99a22e1a0832 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,11 +32,11 @@ def main(): response = client.organizations.get( resource_group_name="rgneon", - organization_name="5", + organization_name="test-org", ) print(response) -# x-ms-original-file: 2024-08-01-preview/Organizations_Get_MaximumSet_Gen.json +# x-ms-original-file: 2025-03-01/Organizations_Get_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_get_postgres_versions_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_get_postgres_versions_maximum_set_gen.py new file mode 100644 index 000000000000..29d36f7c0469 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_get_postgres_versions_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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 organizations_get_postgres_versions_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.organizations.get_postgres_versions( + resource_group_name="rgneon", + ) + print(response) + + +# x-ms-original-file: 2025-03-01/Organizations_GetPostgresVersions_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_get_postgres_versions_minimum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_get_postgres_versions_minimum_set_gen.py new file mode 100644 index 000000000000..fb0bea680eea --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_get_postgres_versions_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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 organizations_get_postgres_versions_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, + 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.organizations.get_postgres_versions( + resource_group_name="rgneon", + ) + print(response) + + +# x-ms-original-file: 2025-03-01/Organizations_GetPostgresVersions_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_list_by_resource_group_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_list_by_resource_group_maximum_set_gen.py index 91d3dc17e60c..ee4e8e8e665f 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_list_by_resource_group_maximum_set_gen.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_list_by_resource_group_maximum_set_gen.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: 2024-08-01-preview/Organizations_ListByResourceGroup_MaximumSet_Gen.json +# x-ms-original-file: 2025-03-01/Organizations_ListByResourceGroup_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_list_by_subscription_maximum_set_gen.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_list_by_subscription_maximum_set_gen.py index 4b00a1f1c1ed..2a05fc3ef57f 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_list_by_subscription_maximum_set_gen.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/organizations_list_by_subscription_maximum_set_gen.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: 2024-08-01-preview/Organizations_ListBySubscription_MaximumSet_Gen.json +# x-ms-original-file: 2025-03-01/Organizations_ListBySubscription_MaximumSet_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 c6ae07db4d99..e0e7b36e3584 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,41 +32,122 @@ def main(): response = client.organizations.begin_update( resource_group_name="rgneon", - organization_name="eRY-J_:", + organization_name="test-org", properties={ "properties": { "companyDetails": { - "businessPhone": "hbeb", - "companyName": "uxn", - "country": "lpajqzptqchuko", - "domain": "krjldeakhwiepvs", - "numberOfEmployees": 23, - "officeAddress": "chpkrlpmfslmawgunjxdllzcrctykq", + "businessPhone": "hucxvzcvpaupqjkgb", + "companyName": "xtul", + "country": "ycmyjdcpyjieemfrthfyxdlvn", + "domain": "snoshqumfsthyofpnrsgyjhszvgtj", + "numberOfEmployees": 12, + "officeAddress": "icirtoqmmozijk", + }, + "marketplaceDetails": { + "offerDetails": { + "offerId": "bunyeeupoedueofwrzej", + "planId": "nlbfiwtslenfwek", + "planName": "ljbmgpkfqklaufacbpml", + "publisherId": "hporaxnopmolttlnkbarw", + "termId": "aedlchikwqckuploswthvshe", + "termUnit": "qbcq", + }, + "subscriptionId": "yxmkfivp", + "subscriptionStatus": "PendingFulfillmentStart", }, "partnerOrganizationProperties": { - "organizationId": "njyoqflcmfwzfsqe", - "organizationName": "J:.._3P", + "organizationId": "fynmpcbivqkwqdfhrmsyusjd", + "organizationName": "entity-name", "singleSignOnProperties": { - "aadDomains": ["kndszgrwzbvvlssvkej"], - "enterpriseAppId": "fpibacregjfncfdsojs", + "aadDomains": ["mdzbelaiphukhe"], + "enterpriseAppId": "urtjzjfr", "singleSignOnState": "Initial", - "singleSignOnUrl": "tmojh", + "singleSignOnUrl": "gcmlwvtxcsjozitm", + }, + }, + "projectProperties": { + "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, }, "userDetails": { - "emailAddress": "3i_%@w8-y.H-p.tvj.dG", - "firstName": "buwwe", - "lastName": "escynjpynkoox", - "phoneNumber": "dlrqoowumy", - "upn": "fwedjamgwwrotcjaucuzdwycfjdqn", + "emailAddress": "test@contoso.com", + "firstName": "zhelh", + "lastName": "zbdhouyeozylnerrc", + "phoneNumber": "zmejenytglrmjnt", + "upn": "mixcikvxlnhkfugetqlngz", }, }, - "tags": {"key8990": "wuvaontoqyttxtikvvahdegcfdfkz"}, + "tags": {"key609": "qyosjypklxtiamqebd"}, }, ).result() print(response) -# x-ms-original-file: 2024-08-01-preview/Organizations_Update_MaximumSet_Gen.json +# x-ms-original-file: 2025-03-01/Organizations_Update_MaximumSet_Gen.json if __name__ == "__main__": main() 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 new file mode 100644 index 000000000000..ae3783c6ce8d --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/projects_create_or_update_maximum_set_gen.py @@ -0,0 +1,114 @@ +# 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_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.projects.begin_create_or_update( + resource_group_name="rgneon", + organization_name="test-org", + project_name="entity-name", + resource={ + "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": 20, "autoscalingLimitMinCu": 26}, + "endpoints": [ + { + "attributes": [{"name": "trhvzyvaqy", "value": "evpkgsskyavybxwwssm"}], + "branchId": "rzsyrhpfbydxtfkpaa", + "endpointType": "read_only", + "entityName": "entity-name", + "projectId": "rtvdeeflqzlrpfzhjqhcsfbldw", + } + ], + "entityName": "entity-name", + "historyRetention": 7, + "pgVersion": 10, + "regionId": "tlcltldfrnxh", + "roles": [ + { + "attributes": [{"name": "trhvzyvaqy", "value": "evpkgsskyavybxwwssm"}], + "branchId": "wxbojkmdgaggkfiwqfakdkbyztm", + "entityName": "entity-name", + "isSuperUser": True, + "permissions": ["myucqecpjriewzohxvadgkhiudnyx"], + } + ], + "storage": 7, + } + }, + ).result() + print(response) + + +# x-ms-original-file: 2025-03-01/Projects_CreateOrUpdate_MaximumSet_Gen.json +if __name__ == "__main__": + main() 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 new file mode 100644 index 000000000000..fe27a447f453 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/projects_delete_maximum_set_gen.py @@ -0,0 +1,42 @@ +# 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_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.projects.delete( + resource_group_name="rgneon", + organization_name="test-org", + project_name="entity-name", + ) + + +# x-ms-original-file: 2025-03-01/Projects_Delete_MaximumSet_Gen.json +if __name__ == "__main__": + main() 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 new file mode 100644 index 000000000000..3b19816b5b52 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/projects_get_connection_uri_maximum_set_gen.py @@ -0,0 +1,51 @@ +# 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_get_connection_uri_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.get_connection_uri( + resource_group_name="rgneon", + organization_name="test-org", + project_name="entity-name", + connection_uri_parameters={ + "branchId": "iimmlbqv", + "databaseName": "xc", + "endpointId": "jcpdvsyjcn", + "isPooled": True, + "projectId": "riuifmoqtorrcffgksvfcobia", + "roleName": "xhmcvsgtp", + }, + ) + print(response) + + +# x-ms-original-file: 2025-03-01/Projects_GetConnectionUri_MaximumSet_Gen.json +if __name__ == "__main__": + main() 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 new file mode 100644 index 000000000000..3c3d3312456d --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/projects_get_maximum_set_gen.py @@ -0,0 +1,43 @@ +# 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_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.projects.get( + resource_group_name="rgneon", + organization_name="test-org", + project_name="entity-name", + ) + print(response) + + +# x-ms-original-file: 2025-03-01/Projects_Get_MaximumSet_Gen.json +if __name__ == "__main__": + main() 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 new file mode 100644 index 000000000000..eb79c2e276e4 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/projects_list_maximum_set_gen.py @@ -0,0 +1,43 @@ +# 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_list_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.list( + resource_group_name="rgneon", + organization_name="test-org", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2025-03-01/Projects_List_MaximumSet_Gen.json +if __name__ == "__main__": + main() 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 new file mode 100644 index 000000000000..2baae801d1b9 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_samples/projects_update_maximum_set_gen.py @@ -0,0 +1,114 @@ +# 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 new file mode 100644 index 000000000000..86a49299c170 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_branches_operations.py @@ -0,0 +1,201 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.neonpostgres import NeonPostgresMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestNeonPostgresMgmtBranchesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(NeonPostgresMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_branches_get(self, resource_group): + response = self.client.branches.get( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + branch_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_branches_begin_create_or_update(self, resource_group): + response = self.client.branches.begin_create_or_update( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + branch_name="str", + resource={ + "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_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): + response = self.client.branches.delete( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + branch_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_branches_list(self, resource_group): + response = self.client.branches.list( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... 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 new file mode 100644 index 000000000000..daad42cfedfc --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_branches_operations_async.py @@ -0,0 +1,206 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.neonpostgres.aio import NeonPostgresMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestNeonPostgresMgmtBranchesOperationsAsync(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_branches_get(self, resource_group): + response = await self.client.branches.get( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + branch_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_branches_begin_create_or_update(self, resource_group): + response = await ( + await self.client.branches.begin_create_or_update( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + branch_name="str", + resource={ + "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_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): + response = await self.client.branches.delete( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + branch_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_branches_list(self, resource_group): + response = self.client.branches.list( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... 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 new file mode 100644 index 000000000000..f56beceb8f73 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_computes_operations.py @@ -0,0 +1,136 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.neonpostgres import NeonPostgresMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class 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): + response = self.client.computes.list( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + branch_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... 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 new file mode 100644 index 000000000000..92ad9469c74b --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_computes_operations_async.py @@ -0,0 +1,141 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.neonpostgres.aio import NeonPostgresMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class 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): + response = self.client.computes.list( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + branch_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... 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 new file mode 100644 index 000000000000..325430c3465d --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_endpoints_operations.py @@ -0,0 +1,134 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.neonpostgres import NeonPostgresMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class 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): + response = self.client.endpoints.list( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + branch_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... 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 new file mode 100644 index 000000000000..34dc96ef044e --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_endpoints_operations_async.py @@ -0,0 +1,139 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.neonpostgres.aio import NeonPostgresMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class 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): + response = self.client.endpoints.list( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + branch_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... 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 new file mode 100644 index 000000000000..717326a88fac --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_neon_databases_operations.py @@ -0,0 +1,132 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.neonpostgres import NeonPostgresMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class 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): + response = self.client.neon_databases.list( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + branch_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... 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 new file mode 100644 index 000000000000..0c2662346220 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_neon_databases_operations_async.py @@ -0,0 +1,137 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.neonpostgres.aio import NeonPostgresMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class 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): + response = self.client.neon_databases.list( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + branch_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... 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 new file mode 100644 index 000000000000..72b953407189 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_neon_roles_operations.py @@ -0,0 +1,134 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.neonpostgres import NeonPostgresMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class 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): + response = self.client.neon_roles.list( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + branch_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... 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 new file mode 100644 index 000000000000..df4b345cb271 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_neon_roles_operations_async.py @@ -0,0 +1,139 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.neonpostgres.aio import NeonPostgresMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class 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): + response = self.client.neon_roles.list( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + branch_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_organizations_operations.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_organizations_operations.py index 0ecd0b56742a..549a925dad82 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_organizations_operations.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_organizations_operations.py @@ -77,6 +77,99 @@ def test_organizations_begin_create_or_update(self, resource_group): "singleSignOnUrl": "str", }, }, + "projectProperties": { + "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, + }, "provisioningState": "str", }, "systemData": { @@ -143,6 +236,99 @@ def test_organizations_begin_update(self, resource_group): "singleSignOnUrl": "str", }, }, + "projectProperties": { + "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, + }, "provisioningState": "str", }, "systemData": { @@ -189,3 +375,13 @@ def test_organizations_list_by_subscription(self, resource_group): result = [r for r in response] # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_organizations_get_postgres_versions(self, resource_group): + response = self.client.organizations.get_postgres_versions( + resource_group_name=resource_group.name, + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_organizations_operations_async.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_organizations_operations_async.py index 027aa22a2f5c..3c870809a97d 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_organizations_operations_async.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_organizations_operations_async.py @@ -79,6 +79,99 @@ async def test_organizations_begin_create_or_update(self, resource_group): "singleSignOnUrl": "str", }, }, + "projectProperties": { + "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, + }, "provisioningState": "str", }, "systemData": { @@ -147,6 +240,99 @@ async def test_organizations_begin_update(self, resource_group): "singleSignOnUrl": "str", }, }, + "projectProperties": { + "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, + }, "provisioningState": "str", }, "systemData": { @@ -196,3 +382,13 @@ async def test_organizations_list_by_subscription(self, resource_group): result = [r async for r in response] # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_organizations_get_postgres_versions(self, resource_group): + response = await self.client.organizations.get_postgres_versions( + resource_group_name=resource_group.name, + ) + + # please add some check logic here by yourself + # ... 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 new file mode 100644 index 000000000000..91aff0fd5c98 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_projects_operations.py @@ -0,0 +1,311 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.neonpostgres import NeonPostgresMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestNeonPostgresMgmtProjectsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(NeonPostgresMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_projects_get(self, resource_group): + response = self.client.projects.get( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_projects_begin_create_or_update(self, resource_group): + response = self.client.projects.begin_create_or_update( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + resource={ + "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_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): + response = self.client.projects.delete( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_projects_list(self, resource_group): + response = self.client.projects.list( + resource_group_name=resource_group.name, + organization_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_projects_get_connection_uri(self, resource_group): + response = self.client.projects.get_connection_uri( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + connection_uri_parameters={ + "branchId": "str", + "connectionStringUri": "str", + "databaseName": "str", + "endpointId": "str", + "isPooled": bool, + "projectId": "str", + "roleName": "str", + }, + ) + + # please add some check logic here by yourself + # ... 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 new file mode 100644 index 000000000000..c161c37f92c9 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/generated_tests/test_neon_postgres_mgmt_projects_operations_async.py @@ -0,0 +1,316 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.neonpostgres.aio import NeonPostgresMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestNeonPostgresMgmtProjectsOperationsAsync(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_projects_get(self, resource_group): + response = await self.client.projects.get( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_projects_begin_create_or_update(self, resource_group): + response = await ( + await self.client.projects.begin_create_or_update( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + resource={ + "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_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): + response = await self.client.projects.delete( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_projects_list(self, resource_group): + response = self.client.projects.list( + resource_group_name=resource_group.name, + organization_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_projects_get_connection_uri(self, resource_group): + response = await self.client.projects.get_connection_uri( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + connection_uri_parameters={ + "branchId": "str", + "connectionStringUri": "str", + "databaseName": "str", + "endpointId": "str", + "isPooled": bool, + "projectId": "str", + "roleName": "str", + }, + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/sdk_packaging.toml b/sdk/neonpostgres/azure-mgmt-neonpostgres/sdk_packaging.toml index 805c0ae5d14f..38306b5c25d8 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/sdk_packaging.toml +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/sdk_packaging.toml @@ -3,7 +3,7 @@ package_name = "azure-mgmt-neonpostgres" package_nspkg = "azure-mgmt-nspkg" package_pprint_name = "Neonpostgres Management" package_doc_id = "" -is_stable = false +is_stable = true is_arm = true need_msrestazure = false need_azuremgmtcore = true diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/setup.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/setup.py index 64312c9ca568..090dc2220bcc 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/setup.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/setup.py @@ -22,11 +22,9 @@ # Version extraction inspired from 'requests' with open( - ( - os.path.join(package_folder_path, "version.py") - if os.path.exists(os.path.join(package_folder_path, "version.py")) - else os.path.join(package_folder_path, "_version.py") - ), + os.path.join(package_folder_path, "version.py") + if os.path.exists(os.path.join(package_folder_path, "version.py")) + else os.path.join(package_folder_path, "_version.py"), "r", ) as fd: version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) @@ -51,7 +49,7 @@ url="https://github.com/Azure/azure-sdk-for-python", keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product classifiers=[ - "Development Status :: 4 - Beta", + "Development Status :: 5 - Production/Stable", "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/tsp-location.yaml b/sdk/neonpostgres/azure-mgmt-neonpostgres/tsp-location.yaml index 83678b856da0..7f6e9ab0ff15 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: 4e3820497caa29ed0efada28a38cb4292cea9d55 +commit: af51fab0cc00ba3eaee7e4710e8fec5894d4bb0c repo: Azure/azure-rest-api-specs additionalDirectories: