Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Self-Help] Feature self-help 2023-09-01-preview #6872

Merged
6 changes: 5 additions & 1 deletion src/self-help/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ Release History

0.1.0
++++++
* Initial release.
* Initial release.

0.2.0
++++++
* Added new commands troubleshooter and solution from public preview version v2023-09-01-preview. Updated contracts for responses.
84 changes: 81 additions & 3 deletions src/self-help/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,95 @@ az extension add --name self-help
_Examples:_

```
# Show diagnostic for a resource.
# Shows diagnostic for a resource.
az self-help diagnostic show --diagnostic-name {diagnostic-name} --scope {scope}
```

### _"Solution"_ commands

- #### Create Solution for a resource

_Examples:_

```
# Creates a solution for a resource
az self-help solution create --solution-name {solution-name} --trigger-criteria {trigger-criteria} --parameters {parameters} --scope {scope}
```

- #### Show Solution for a resource

_Examples:_

```
# Shows solution for a resource.
az self-help solution show --solution-name {solution-name} --scope {scope}
```

- #### Update Solution for a resource

_Examples:_

```
# Updates solution for a resource.
az self-help solution update --solution-name {solution-name} --trigger-criteria {trigger-criteria} --parameters {parameters} --scope {scope}
```

### _"Troubleshooter"_ commands

- #### Create Troubleshooter for a resource

_Examples:_

```
# Creates a troubleshooter for a resource
az self-help troubleshooter create --troubleshooter-name {troubleshooter-name} --solution-id {solution-id} --parameters {parameters} --scope {scope}
```

- #### Show troubleshooter for a resource

_Examples:_

```
# Show troubleshooter for a resource.
az self-help troubleshooter show --troubleshooter-name {troubleshooter-name} --scope {scope}
```

- #### Restart troubleshooter for a resource

_Examples:_

```
# Restarts troubleshooter for a resource.
az self-help troubleshooter restart --troubleshooter-name {troubleshooter-name} --scope {scope}
```

- #### End troubleshooter for a resource

_Examples:_

```
# Ends troubleshooter for a resource.
az self-help troubleshooter show --troubleshooter-name {troubleshooter-name} --scope {scope}
```

- #### Continue troubleshooter for a resource

_Examples:_

```
# Continues troubleshooter for a resource.
az self-help troubleshooter continue --troubleshooter-name {troubleshooter-name} --step-id {step-id} --responses [] --scope {scope}
```

### _"Check-Name-Availability"_ commands

- #### CheckName Availabiliity

_Examples:_

```
# Checks name available of a diagnostic resource.
az self-help check-name-availability --scope subscriptionId/{subId} --name {diagnostic-name} --type 'Microsoft.Help/diagnostics'
# Check Resource Uniqueness
az self-help check-name-availability --scope subscriptions/{subId} --name {diagnostic-name} --type 'Microsoft.Help/diagnostics'
az self-help check-name-availability --scope subscriptions/{subId} --name {solution-name} --type 'Microsoft.Help/solutions'
az self-help check-name-availability --scope subscriptions/{subId} --name {troubleshooter-name} --type 'Microsoft.Help/troubleshooters'
```
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@
is_preview=True,
)
class CheckNameAvailability(AAZCommand):
"""This API is used to check the uniqueness of a resource name used for a diagnostic check.
"""This API is used to check the uniqueness of a resource name used for a diagnostic, troubleshooter or solutions

:example: Check Diagnostic Resource Uniqueness
az self-help check-name-availability --scope subscriptionId/{subId} --name {diagnostic-name} --type 'Microsoft.Help/diagnostics'
:example: Check Resource Uniqueness
az self-help check-name-availability --scope subscriptions/{subId} --name {diagnostic-name} --type 'Microsoft.Help/diagnostics'
az self-help check-name-availability --scope subscriptions/{subId} --name {solution-name} --type 'Microsoft.Help/solutions'
az self-help check-name-availability --scope subscriptions/{subId} --name {troubleshooter-name} --type 'Microsoft.Help/troubleshooters'
"""

_aaz_info = {
"version": "2023-01-01-preview",
"version": "2023-09-01-preview",
"resources": [
["mgmt-plane", "/{scope}/providers/microsoft.help/checknameavailability", "2023-01-01-preview"],
["mgmt-plane", "/{scope}/providers/microsoft.help/checknameavailability", "2023-09-01-preview"],
]
}

Expand Down Expand Up @@ -68,7 +70,7 @@ def _build_arguments_schema(cls, *args, **kwargs):

def _execute_operations(self):
self.pre_operations()
self.DiagnosticsCheckNameAvailability(ctx=self.ctx)()
self.CheckNameAvailabilityPost(ctx=self.ctx)()
self.post_operations()

@register_callback
Expand All @@ -83,7 +85,7 @@ def _output(self, *args, **kwargs):
result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True)
return result

class DiagnosticsCheckNameAvailability(AAZHttpOperation):
class CheckNameAvailabilityPost(AAZHttpOperation):
CLIENT_TYPE = "MgmtClient"

def __call__(self, *args, **kwargs):
Expand Down Expand Up @@ -124,7 +126,7 @@ def url_parameters(self):
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2023-01-01-preview",
"api-version", "2023-09-01-preview",
required=True,
),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class Create(AAZCommand):
"""

_aaz_info = {
"version": "2023-01-01-preview",
"version": "2023-09-01-preview",
"resources": [
["mgmt-plane", "/{scope}/providers/microsoft.help/diagnostics/{}", "2023-01-01-preview"],
["mgmt-plane", "/{scope}/providers/microsoft.help/diagnostics/{}", "2023-09-01-preview"],
]
}

Expand All @@ -48,7 +48,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
_args_schema = cls._args_schema
_args_schema.diagnostic_name = AAZStrArg(
options=["--diagnostic-name"],
help="unique resource name for diagnostic proxy resources.",
help="Unique resource name for insight resources",
required=True,
fmt=AAZStrArgFormat(
pattern="^[A-Za-z0-9-+@()_]+$",
Expand Down Expand Up @@ -123,16 +123,16 @@ def __call__(self, *args, **kwargs):
return self.client.build_lro_polling(
self.ctx.args.no_wait,
session,
self.on_201,
self.on_200_201,
self.on_error,
lro_options={"final-state-via": "azure-async-operation"},
path_format_arguments=self.url_parameters,
)
if session.http_response.status_code in [201]:
if session.http_response.status_code in [200, 201]:
return self.client.build_lro_polling(
self.ctx.args.no_wait,
session,
self.on_201,
self.on_200_201,
self.on_error,
lro_options={"final-state-via": "azure-async-operation"},
path_format_arguments=self.url_parameters,
Expand Down Expand Up @@ -174,7 +174,7 @@ def url_parameters(self):
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2023-01-01-preview",
"api-version", "2023-09-01-preview",
required=True,
),
}
Expand Down Expand Up @@ -225,42 +225,42 @@ def content(self):

return self.serialize_content(_content_value)

def on_201(self, session):
def on_200_201(self, session):
data = self.deserialize_http_content(session)
self.ctx.set_var(
"instance",
data,
schema_builder=self._build_schema_on_201
schema_builder=self._build_schema_on_200_201
)

_schema_on_201 = None
_schema_on_200_201 = None

@classmethod
def _build_schema_on_201(cls):
if cls._schema_on_201 is not None:
return cls._schema_on_201
def _build_schema_on_200_201(cls):
if cls._schema_on_200_201 is not None:
return cls._schema_on_200_201

cls._schema_on_201 = AAZObjectType()
cls._schema_on_200_201 = AAZObjectType()

_schema_on_201 = cls._schema_on_201
_schema_on_201.id = AAZStrType(
_schema_on_200_201 = cls._schema_on_200_201
_schema_on_200_201.id = AAZStrType(
flags={"read_only": True},
)
_schema_on_201.name = AAZStrType(
_schema_on_200_201.name = AAZStrType(
flags={"read_only": True},
)
_schema_on_201.properties = AAZObjectType(
_schema_on_200_201.properties = AAZObjectType(
flags={"client_flatten": True},
)
_schema_on_201.system_data = AAZObjectType(
_schema_on_200_201.system_data = AAZObjectType(
serialized_name="systemData",
flags={"read_only": True},
)
_schema_on_201.type = AAZStrType(
_schema_on_200_201.type = AAZStrType(
flags={"read_only": True},
)

properties = cls._schema_on_201.properties
properties = cls._schema_on_200_201.properties
properties.accepted_at = AAZStrType(
serialized_name="acceptedAt",
flags={"read_only": True},
Expand All @@ -277,10 +277,10 @@ def _build_schema_on_201(cls):
flags={"read_only": True},
)

diagnostics = cls._schema_on_201.properties.diagnostics
diagnostics = cls._schema_on_200_201.properties.diagnostics
diagnostics.Element = AAZObjectType()

_element = cls._schema_on_201.properties.diagnostics.Element
_element = cls._schema_on_200_201.properties.diagnostics.Element
_element.error = AAZObjectType()
_CreateHelper._build_schema_error_read(_element.error)
_element.insights = AAZListType()
Expand All @@ -289,35 +289,35 @@ def _build_schema_on_201(cls):
)
_element.status = AAZStrType()

insights = cls._schema_on_201.properties.diagnostics.Element.insights
insights = cls._schema_on_200_201.properties.diagnostics.Element.insights
insights.Element = AAZObjectType()

_element = cls._schema_on_201.properties.diagnostics.Element.insights.Element
_element = cls._schema_on_200_201.properties.diagnostics.Element.insights.Element
_element.id = AAZStrType()
_element.importance_level = AAZStrType(
serialized_name="importanceLevel",
)
_element.results = AAZStrType()
_element.title = AAZStrType()

global_parameters = cls._schema_on_201.properties.global_parameters
global_parameters = cls._schema_on_200_201.properties.global_parameters
global_parameters.Element = AAZStrType()

insights = cls._schema_on_201.properties.insights
insights = cls._schema_on_200_201.properties.insights
insights.Element = AAZObjectType()

_element = cls._schema_on_201.properties.insights.Element
_element = cls._schema_on_200_201.properties.insights.Element
_element.additional_parameters = AAZDictType(
serialized_name="additionalParameters",
)
_element.solution_id = AAZStrType(
serialized_name="solutionId",
)

additional_parameters = cls._schema_on_201.properties.insights.Element.additional_parameters
additional_parameters = cls._schema_on_200_201.properties.insights.Element.additional_parameters
additional_parameters.Element = AAZStrType()

system_data = cls._schema_on_201.system_data
system_data = cls._schema_on_200_201.system_data
system_data.created_at = AAZStrType(
serialized_name="createdAt",
)
Expand All @@ -337,7 +337,7 @@ def _build_schema_on_201(cls):
serialized_name="lastModifiedByType",
)

return cls._schema_on_201
return cls._schema_on_200_201


class _CreateHelper:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class Show(AAZCommand):
"""

_aaz_info = {
"version": "2023-01-01-preview",
"version": "2023-09-01-preview",
"resources": [
["mgmt-plane", "/{scope}/providers/microsoft.help/diagnostics/{}", "2023-01-01-preview"],
["mgmt-plane", "/{scope}/providers/microsoft.help/diagnostics/{}", "2023-09-01-preview"],
]
}

Expand All @@ -47,7 +47,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
_args_schema = cls._args_schema
_args_schema.diagnostic_name = AAZStrArg(
options=["--diagnostic-name"],
help="unique resource name for diagnostic proxy resources",
help="Unique resource name for insight resources",
required=True,
fmt=AAZStrArgFormat(
pattern="^[A-Za-z0-9-+@()_]+$",
Expand Down Expand Up @@ -124,7 +124,7 @@ def url_parameters(self):
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2023-01-01-preview",
"api-version", "2023-09-01-preview",
required=True,
),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Wait(AAZWaitCommand):

_aaz_info = {
"resources": [
["mgmt-plane", "/{scope}/providers/microsoft.help/diagnostics/{}", "2023-01-01-preview"],
["mgmt-plane", "/{scope}/providers/microsoft.help/diagnostics/{}", "2023-09-01-preview"],
]
}

Expand All @@ -42,7 +42,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
_args_schema = cls._args_schema
_args_schema.diagnostic_name = AAZStrArg(
options=["--diagnostic-name"],
help="unique resource name for diagnostic proxy resources",
help="Unique resource name for insight resources",
required=True,
fmt=AAZStrArgFormat(
pattern="^[A-Za-z0-9-+@()_]+$",
Expand Down Expand Up @@ -119,7 +119,7 @@ def url_parameters(self):
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2023-01-01-preview",
"api-version", "2023-09-01-preview",
required=True,
),
}
Expand Down
Loading