-
Notifications
You must be signed in to change notification settings - Fork 1.5k
{Application-insights} Migrate az monitor app-insights data-plane using codegen tool
#8641
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
807f634
migrate app-insights data-plane
AllyW fde32eb
fix event show
AllyW 27e4b25
fix data plane of app insights
AllyW 7732bfe
fix style
AllyW 9b55d24
fix style
AllyW 69e756d
add test
AllyW 3c07885
adjust min version
AllyW 7912eb0
set version
AllyW 4581365
adjust help
AllyW 35bcfeb
remove data plane sdk
AllyW 601621d
fix doc link
AllyW 82ed271
add breaking change
AllyW File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,3 +8,4 @@ | |
| # pylint: skip-file | ||
| # flake8: noqa | ||
|
|
||
| from ._clients import * | ||
49 changes: 49 additions & 0 deletions
49
src/application-insights/azext_applicationinsights/aaz/latest/_clients.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # 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 aaz-dev-tools | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| # pylint: skip-file | ||
| # flake8: noqa | ||
|
|
||
| from azure.cli.core.aaz import * | ||
|
|
||
|
|
||
| @register_client("AAZMicrosoftInsightsDataPlaneClient_application_insights") | ||
| class AAZMicrosoftInsightsDataPlaneClient(AAZBaseClient): | ||
| _CLOUD_HOST_TEMPLATES = { | ||
| CloudNameEnum.AzureChinaCloud: "https://api.applicationinsights.azure.cn", | ||
| CloudNameEnum.AzureCloud: "https://api.applicationinsights.io", | ||
| CloudNameEnum.AzureUSGovernment: "https://api.applicationinsights.us", | ||
| } | ||
| _CLOUD_HOST_METADATA_INDEX = "appInsightsResourceId" | ||
|
|
||
| _AAD_CREDENTIAL_SCOPES = [ | ||
| "https://api.applicationinsights.io/.default", | ||
| ] | ||
|
|
||
| @classmethod | ||
| def _build_base_url(cls, ctx, **kwargs): | ||
| endpoint = cls.get_cloud_endpoint(ctx, cls._CLOUD_HOST_METADATA_INDEX) | ||
| if not endpoint: | ||
| endpoint = cls._CLOUD_HOST_TEMPLATES.get(ctx.cli_ctx.cloud.name, None) | ||
| return endpoint | ||
|
|
||
| @classmethod | ||
| def _build_configuration(cls, ctx, credential, **kwargs): | ||
| return AAZClientConfiguration( | ||
| credential=credential, | ||
| credential_scopes=cls._AAD_CREDENTIAL_SCOPES, | ||
| **kwargs | ||
| ) | ||
|
|
||
|
|
||
| class _AAZMicrosoftInsightsDataPlaneClientHelper: | ||
| """Helper class for AAZMicrosoftInsightsDataPlaneClient""" | ||
|
|
||
|
|
||
| __all__ = [ | ||
| "AAZMicrosoftInsightsDataPlaneClient", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
209 changes: 209 additions & 0 deletions
209
...tion-insights/azext_applicationinsights/aaz/latest/monitor/app_insights/_query_execute.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,209 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # 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 aaz-dev-tools | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| # pylint: skip-file | ||
| # flake8: noqa | ||
|
|
||
| from azure.cli.core.aaz import * | ||
|
|
||
|
|
||
| class QueryExecute(AAZCommand): | ||
| """Executes an Analytics query for data. Doc https://dev.applicationinsights.io/documentation/Using-the-API/Query is an example for using POST with an Analytics query. | ||
| """ | ||
|
|
||
| _aaz_info = { | ||
| "version": "v1", | ||
| "resources": [ | ||
| ["data-plane:microsoft.insights", "/apps/{}/query", "v1"], | ||
| ] | ||
| } | ||
|
|
||
| def _handler(self, command_args): | ||
| super()._handler(command_args) | ||
| self._execute_operations() | ||
| return self._output() | ||
|
|
||
| _args_schema = None | ||
|
|
||
| @classmethod | ||
| def _build_arguments_schema(cls, *args, **kwargs): | ||
| if cls._args_schema is not None: | ||
| return cls._args_schema | ||
| cls._args_schema = super()._build_arguments_schema(*args, **kwargs) | ||
|
|
||
| # define Arg Group "" | ||
|
|
||
| _args_schema = cls._args_schema | ||
| _args_schema.app_id = AAZStrArg( | ||
| options=["--app-id"], | ||
| help="ID of the application. This is Application ID from the API Access settings blade in the Azure portal.", | ||
| required=True, | ||
| ) | ||
|
|
||
| # define Arg Group "Body" | ||
|
|
||
| _args_schema = cls._args_schema | ||
| _args_schema.applications = AAZListArg( | ||
| options=["--applications"], | ||
| arg_group="Body", | ||
| help="A list of Application IDs for cross-application queries.", | ||
| ) | ||
| _args_schema.query = AAZStrArg( | ||
| options=["--query"], | ||
| arg_group="Body", | ||
| help="The query to execute.", | ||
| required=True, | ||
| ) | ||
| _args_schema.timespan = AAZStrArg( | ||
| options=["--timespan"], | ||
| arg_group="Body", | ||
| help="Optional. The timespan over which to query data. This is an ISO8601 time period value. This timespan is applied in addition to any that are specified in the query expression.", | ||
| ) | ||
|
|
||
| applications = cls._args_schema.applications | ||
| applications.Element = AAZStrArg() | ||
| return cls._args_schema | ||
|
|
||
| def _execute_operations(self): | ||
| self.pre_operations() | ||
| self.QueryExecute(ctx=self.ctx)() | ||
| self.post_operations() | ||
|
|
||
| @register_callback | ||
| def pre_operations(self): | ||
| pass | ||
|
|
||
| @register_callback | ||
| def post_operations(self): | ||
| pass | ||
|
|
||
| def _output(self, *args, **kwargs): | ||
| result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) | ||
| return result | ||
|
|
||
| class QueryExecute(AAZHttpOperation): | ||
| CLIENT_TYPE = "AAZMicrosoftInsightsDataPlaneClient_application_insights" | ||
|
|
||
| def __call__(self, *args, **kwargs): | ||
| request = self.make_request() | ||
| session = self.client.send_request(request=request, stream=False, **kwargs) | ||
| if session.http_response.status_code in [200]: | ||
| return self.on_200(session) | ||
|
|
||
| return self.on_error(session.http_response) | ||
|
|
||
| @property | ||
| def url(self): | ||
| return self.client.format_url( | ||
| "/v1/apps/{appId}/query", | ||
| **self.url_parameters | ||
| ) | ||
|
|
||
| @property | ||
| def method(self): | ||
| return "POST" | ||
|
|
||
| @property | ||
| def error_format(self): | ||
| return "ODataV4Format" | ||
|
|
||
| @property | ||
| def url_parameters(self): | ||
| parameters = { | ||
| **self.serialize_url_param( | ||
| "appId", self.ctx.args.app_id, | ||
| required=True, | ||
| ), | ||
| } | ||
| return parameters | ||
|
|
||
| @property | ||
| def header_parameters(self): | ||
| parameters = { | ||
| **self.serialize_header_param( | ||
| "Content-Type", "application/json", | ||
| ), | ||
| **self.serialize_header_param( | ||
| "Accept", "application/json", | ||
| ), | ||
| } | ||
| return parameters | ||
|
|
||
| @property | ||
| def content(self): | ||
| _content_value, _builder = self.new_content_builder( | ||
| self.ctx.args, | ||
| typ=AAZObjectType, | ||
| typ_kwargs={"flags": {"required": True, "client_flatten": True}} | ||
| ) | ||
| _builder.set_prop("applications", AAZListType, ".applications") | ||
| _builder.set_prop("query", AAZStrType, ".query", typ_kwargs={"flags": {"required": True}}) | ||
| _builder.set_prop("timespan", AAZStrType, ".timespan") | ||
|
|
||
| applications = _builder.get(".applications") | ||
| if applications is not None: | ||
| applications.set_elements(AAZStrType, ".") | ||
|
|
||
| return self.serialize_content(_content_value) | ||
|
|
||
| def on_200(self, session): | ||
| data = self.deserialize_http_content(session) | ||
| self.ctx.set_var( | ||
| "instance", | ||
| data, | ||
| schema_builder=self._build_schema_on_200 | ||
| ) | ||
|
|
||
| _schema_on_200 = None | ||
|
|
||
| @classmethod | ||
| def _build_schema_on_200(cls): | ||
| if cls._schema_on_200 is not None: | ||
| return cls._schema_on_200 | ||
|
|
||
| cls._schema_on_200 = AAZObjectType() | ||
|
|
||
| _schema_on_200 = cls._schema_on_200 | ||
| _schema_on_200.tables = AAZListType( | ||
| flags={"required": True}, | ||
| ) | ||
|
|
||
| tables = cls._schema_on_200.tables | ||
| tables.Element = AAZObjectType() | ||
|
|
||
| _element = cls._schema_on_200.tables.Element | ||
| _element.columns = AAZListType( | ||
| flags={"required": True}, | ||
| ) | ||
| _element.name = AAZStrType( | ||
| flags={"required": True}, | ||
| ) | ||
| _element.rows = AAZListType( | ||
| flags={"required": True}, | ||
| ) | ||
|
|
||
| columns = cls._schema_on_200.tables.Element.columns | ||
| columns.Element = AAZObjectType() | ||
|
|
||
| _element = cls._schema_on_200.tables.Element.columns.Element | ||
| _element.name = AAZStrType() | ||
| _element.type = AAZStrType() | ||
|
|
||
| rows = cls._schema_on_200.tables.Element.rows | ||
| rows.Element = AAZListType() | ||
|
|
||
| _element = cls._schema_on_200.tables.Element.rows.Element | ||
| _element.Element = AAZAnyType() | ||
|
|
||
| return cls._schema_on_200 | ||
|
|
||
|
|
||
| class _QueryExecuteHelper: | ||
| """Helper class for QueryExecute""" | ||
|
|
||
|
|
||
| __all__ = ["QueryExecute"] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.