Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"neon postgres",
)
class __CMDGroup(AAZCommandGroup):
"""Manage Neon Postgres
"""Manage Neon Serverless Postgres resources including organizations, projects, and branches.
"""
pass

Expand Down
67 changes: 35 additions & 32 deletions src/neon/azext_neon/aaz/latest/neon/postgres/branch/_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"neon postgres branch create",
)
class Create(AAZCommand):
"""Create a Branch
"""Create a new branch in a Neon project.

:example: Create a Branch
az neon postgres branch create --resource-group rgneon --organization-name org-cli-test --project-name old-frost-16758796 --branch-name test-branch --entity-name test-branch --role-name test_role --database-name testneondb
Expand Down Expand Up @@ -47,32 +47,35 @@ def _build_arguments_schema(cls, *args, **kwargs):
_args_schema = cls._args_schema
_args_schema.branch_name = AAZStrArg(
options=["-n", "--name", "--branch-name"],
help="The name of the Branch",
help="Name of the Neon branch.",
required=True,
fmt=AAZStrArgFormat(
pattern="^\\S.{0,62}\\S$|^\\S$",
),
)
_args_schema.organization_name = AAZStrArg(
options=["--organization-name"],
help="Name of the Neon Organizations resource",
help="Name of the Neon organization.",
required=True,
fmt=AAZStrArgFormat(
pattern="^[a-zA-Z0-9][a-zA-Z0-9_\\-.: ]*$",
max_length=50,
min_length=1,
),
blank=AAZPromptInput(
msg="Please provide Neon Organization name:",
),
)
_args_schema.project_name = AAZStrArg(
options=["--project-name"],
help="The Id of the Neon Project.",
help="Name of the Neon project.",
required=True,
fmt=AAZStrArgFormat(
pattern="^\\S.{0,62}\\S$|^\\S$",
),
)
_args_schema.resource_group = AAZResourceGroupNameArg(
help="The name of the Azure resource group",
help="Name of the Azure resource group.",
required=True,
)

Expand Down Expand Up @@ -107,31 +110,31 @@ def _build_arguments_schema(cls, *args, **kwargs):
)
return cls._args_schema

_args_models_attributes_create = None
_args_attributes_create = None

@classmethod
def _build_args_models_attributes_create(cls, _schema):
if cls._args_models_attributes_create is not None:
_schema.name = cls._args_models_attributes_create.name
_schema.value = cls._args_models_attributes_create.value
def _build_args_attributes_create(cls, _schema):
if cls._args_attributes_create is not None:
_schema.name = cls._args_attributes_create.name
_schema.value = cls._args_attributes_create.value
return

cls._args_models_attributes_create = AAZObjectArg()
cls._args_attributes_create = AAZObjectArg()

models_attributes_create = cls._args_models_attributes_create
models_attributes_create.name = AAZStrArg(
attributes_create = cls._args_attributes_create
attributes_create.name = AAZStrArg(
options=["name"],
help="Name of the attribute",
required=True,
)
models_attributes_create.value = AAZStrArg(
attributes_create.value = AAZStrArg(
options=["value"],
help="Value of the attribute",
required=True,
)

_schema.name = cls._args_models_attributes_create.name
_schema.value = cls._args_models_attributes_create.value
_schema.name = cls._args_attributes_create.name
_schema.value = cls._args_attributes_create.value

def _execute_operations(self):
self.pre_operations()
Expand Down Expand Up @@ -326,7 +329,7 @@ def _build_schema_on_200_201(cls):

attributes = cls._schema_on_200_201.properties.attributes
attributes.Element = AAZObjectType()
_CreateHelper._build_schema_models_attributes_read(attributes.Element)
_CreateHelper._build_schema_attributes_read(attributes.Element)

databases = cls._schema_on_200_201.properties.databases
databases.Element = AAZObjectType()
Expand Down Expand Up @@ -357,7 +360,7 @@ def _build_schema_on_200_201(cls):

attributes = cls._schema_on_200_201.properties.databases.Element.attributes
attributes.Element = AAZObjectType()
_CreateHelper._build_schema_models_attributes_read(attributes.Element)
_CreateHelper._build_schema_attributes_read(attributes.Element)

endpoints = cls._schema_on_200_201.properties.endpoints
endpoints.Element = AAZObjectType()
Expand Down Expand Up @@ -391,7 +394,7 @@ def _build_schema_on_200_201(cls):

attributes = cls._schema_on_200_201.properties.endpoints.Element.attributes
attributes.Element = AAZObjectType()
_CreateHelper._build_schema_models_attributes_read(attributes.Element)
_CreateHelper._build_schema_attributes_read(attributes.Element)

roles = cls._schema_on_200_201.properties.roles
roles.Element = AAZObjectType()
Expand Down Expand Up @@ -423,7 +426,7 @@ def _build_schema_on_200_201(cls):

attributes = cls._schema_on_200_201.properties.roles.Element.attributes
attributes.Element = AAZObjectType()
_CreateHelper._build_schema_models_attributes_read(attributes.Element)
_CreateHelper._build_schema_attributes_read(attributes.Element)

permissions = cls._schema_on_200_201.properties.roles.Element.permissions
permissions.Element = AAZStrType()
Expand Down Expand Up @@ -455,33 +458,33 @@ class _CreateHelper:
"""Helper class for Create"""

@classmethod
def _build_schema_models_attributes_create(cls, _builder):
def _build_schema_attributes_create(cls, _builder):
if _builder is None:
return
_builder.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}})
_builder.set_prop("value", AAZStrType, ".value", typ_kwargs={"flags": {"required": True}})

_schema_models_attributes_read = None
_schema_attributes_read = None

@classmethod
def _build_schema_models_attributes_read(cls, _schema):
if cls._schema_models_attributes_read is not None:
_schema.name = cls._schema_models_attributes_read.name
_schema.value = cls._schema_models_attributes_read.value
def _build_schema_attributes_read(cls, _schema):
if cls._schema_attributes_read is not None:
_schema.name = cls._schema_attributes_read.name
_schema.value = cls._schema_attributes_read.value
return

cls._schema_models_attributes_read = _schema_models_attributes_read = AAZObjectType()
cls._schema_attributes_read = _schema_attributes_read = AAZObjectType()

models_attributes_read = _schema_models_attributes_read
models_attributes_read.name = AAZStrType(
attributes_read = _schema_attributes_read
attributes_read.name = AAZStrType(
flags={"required": True},
)
models_attributes_read.value = AAZStrType(
attributes_read.value = AAZStrType(
flags={"required": True},
)

_schema.name = cls._schema_models_attributes_read.name
_schema.value = cls._schema_models_attributes_read.value
_schema.name = cls._schema_attributes_read.name
_schema.value = cls._schema_attributes_read.value


__all__ = ["Create"]
13 changes: 8 additions & 5 deletions src/neon/azext_neon/aaz/latest/neon/postgres/branch/_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
confirmation="Are you sure you want to perform this operation?",
)
class Delete(AAZCommand):
"""Delete a Branch
"""Delete a branch from a Neon project.

:example: Delete Branch
az neon postgres branch delete --subscription 38a546de-5736-48e8-a69a-5cc636794112 --resource-group rgneon --organization-name org-cli-test --project-id old-frost-16758796 --branch-id br-spring-field-a8vje3tr
Expand Down Expand Up @@ -47,7 +47,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
_args_schema = cls._args_schema
_args_schema.branch_id = AAZStrArg(
options=["--branch-id"],
help="The id of the Neon Branch resource",
help="Id of the Neon branch",
required=True,
id_part="child_name_2",
fmt=AAZStrArgFormat(
Expand All @@ -56,26 +56,29 @@ def _build_arguments_schema(cls, *args, **kwargs):
)
_args_schema.organization_name = AAZStrArg(
options=["--organization-name"],
help="Name of the Neon Organizations resource",
help="Name of the Neon organization.",
required=True,
id_part="name",
fmt=AAZStrArgFormat(
pattern="^[a-zA-Z0-9][a-zA-Z0-9_\\-.: ]*$",
max_length=50,
min_length=1,
),
blank=AAZPromptInput(
msg="Please provide Neon Organization name:",
),
)
_args_schema.project_id = AAZStrArg(
options=["--project-id"],
help="The id of the Neon Project resource.",
help="Id of the Neon project",
required=True,
id_part="child_name_1",
fmt=AAZStrArgFormat(
pattern="^\\S.{0,62}\\S$|^\\S$",
),
)
_args_schema.resource_group = AAZResourceGroupNameArg(
help="The name of the Azure resource group",
help="Name of the Azure resource group.",
required=True,
)
return cls._args_schema
Expand Down
41 changes: 22 additions & 19 deletions src/neon/azext_neon/aaz/latest/neon/postgres/branch/_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"neon postgres branch list",
)
class List(AAZCommand):
"""List Branch resources by Project
"""List all branches in a Neon project.

:example: List Branches under a Project
az neon postgres branch list --subscription 38a546de-5736-48e8-a69a-5cc636794112 --resource-group rgneon --organization-name org-cli-test --project-id old-frost-16758796
Expand Down Expand Up @@ -47,24 +47,27 @@ def _build_arguments_schema(cls, *args, **kwargs):
_args_schema = cls._args_schema
_args_schema.organization_name = AAZStrArg(
options=["--organization-name"],
help="Name of the Neon Organizations resource",
help="Name of the Neon organization.",
required=True,
fmt=AAZStrArgFormat(
pattern="^[a-zA-Z0-9][a-zA-Z0-9_\\-.: ]*$",
max_length=50,
min_length=1,
),
blank=AAZPromptInput(
msg="Please provide Neon Organization name:",
),
)
_args_schema.project_id = AAZStrArg(
options=["--project-id"],
help="The id of the Neon Project resource.",
help="Id of the Neon project",
required=True,
fmt=AAZStrArgFormat(
pattern="^\\S.{0,62}\\S$|^\\S$",
),
)
_args_schema.resource_group = AAZResourceGroupNameArg(
help="The name of the Azure resource group",
help="Name of the Azure resource group.",
required=True,
)
return cls._args_schema
Expand Down Expand Up @@ -233,7 +236,7 @@ def _build_schema_on_200(cls):

attributes = cls._schema_on_200.value.Element.properties.attributes
attributes.Element = AAZObjectType()
_ListHelper._build_schema_models_attributes_read(attributes.Element)
_ListHelper._build_schema_attributes_read(attributes.Element)

databases = cls._schema_on_200.value.Element.properties.databases
databases.Element = AAZObjectType()
Expand Down Expand Up @@ -264,7 +267,7 @@ def _build_schema_on_200(cls):

attributes = cls._schema_on_200.value.Element.properties.databases.Element.attributes
attributes.Element = AAZObjectType()
_ListHelper._build_schema_models_attributes_read(attributes.Element)
_ListHelper._build_schema_attributes_read(attributes.Element)

endpoints = cls._schema_on_200.value.Element.properties.endpoints
endpoints.Element = AAZObjectType()
Expand Down Expand Up @@ -298,7 +301,7 @@ def _build_schema_on_200(cls):

attributes = cls._schema_on_200.value.Element.properties.endpoints.Element.attributes
attributes.Element = AAZObjectType()
_ListHelper._build_schema_models_attributes_read(attributes.Element)
_ListHelper._build_schema_attributes_read(attributes.Element)

roles = cls._schema_on_200.value.Element.properties.roles
roles.Element = AAZObjectType()
Expand Down Expand Up @@ -330,7 +333,7 @@ def _build_schema_on_200(cls):

attributes = cls._schema_on_200.value.Element.properties.roles.Element.attributes
attributes.Element = AAZObjectType()
_ListHelper._build_schema_models_attributes_read(attributes.Element)
_ListHelper._build_schema_attributes_read(attributes.Element)

permissions = cls._schema_on_200.value.Element.properties.roles.Element.permissions
permissions.Element = AAZStrType()
Expand Down Expand Up @@ -361,27 +364,27 @@ def _build_schema_on_200(cls):
class _ListHelper:
"""Helper class for List"""

_schema_models_attributes_read = None
_schema_attributes_read = None

@classmethod
def _build_schema_models_attributes_read(cls, _schema):
if cls._schema_models_attributes_read is not None:
_schema.name = cls._schema_models_attributes_read.name
_schema.value = cls._schema_models_attributes_read.value
def _build_schema_attributes_read(cls, _schema):
if cls._schema_attributes_read is not None:
_schema.name = cls._schema_attributes_read.name
_schema.value = cls._schema_attributes_read.value
return

cls._schema_models_attributes_read = _schema_models_attributes_read = AAZObjectType()
cls._schema_attributes_read = _schema_attributes_read = AAZObjectType()

models_attributes_read = _schema_models_attributes_read
models_attributes_read.name = AAZStrType(
attributes_read = _schema_attributes_read
attributes_read.name = AAZStrType(
flags={"required": True},
)
models_attributes_read.value = AAZStrType(
attributes_read.value = AAZStrType(
flags={"required": True},
)

_schema.name = cls._schema_models_attributes_read.name
_schema.value = cls._schema_models_attributes_read.value
_schema.name = cls._schema_attributes_read.name
_schema.value = cls._schema_attributes_read.value


__all__ = ["List"]
Loading
Loading