From 5b9a6ae3e29144c72591054700d1385d6007c785 Mon Sep 17 00:00:00 2001 From: Azure CLI Bot Date: Fri, 18 Feb 2022 10:13:35 +0800 Subject: [PATCH] code and test (#23047) Co-authored-by: PythonSdkPipelines --- .../azure-mgmt-loganalytics/CHANGELOG.md | 6 ++ .../azure-mgmt-loganalytics/_meta.json | 4 +- .../azure/mgmt/loganalytics/_version.py | 2 +- .../aio/operations/_tables_operations.py | 55 +++++++++++- .../_log_analytics_management_client_enums.py | 6 +- .../mgmt/loganalytics/models/_models_py3.py | 53 +++++------ .../operations/_tables_operations.py | 90 +++++++++++++++++++ 7 files changed, 179 insertions(+), 37 deletions(-) diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/CHANGELOG.md b/sdk/loganalytics/azure-mgmt-loganalytics/CHANGELOG.md index 8af761260e8a..06d27bab6e4b 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/CHANGELOG.md +++ b/sdk/loganalytics/azure-mgmt-loganalytics/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 13.0.0b2 (2022-02-14) + +**Features** + + - Added operation TablesOperations.migrate + ## 13.0.0b1 (2022-01-18) **Features** diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/_meta.json b/sdk/loganalytics/azure-mgmt-loganalytics/_meta.json index dc83ea324c67..8c13adfd1daa 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/_meta.json +++ b/sdk/loganalytics/azure-mgmt-loganalytics/_meta.json @@ -4,8 +4,8 @@ "@autorest/python@5.12.0", "@autorest/modelerfour@4.19.3" ], - "commit": "23ca45b7dfce24112bc686bae70c4424f33ae69e", + "commit": "24b1f9ed9a0768a55b14cced1761a40f7c12b6d2", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/operationalinsights/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/operationalinsights/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/operationalinsights/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_version.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_version.py index bd75dfe22ca1..28cf8b467ac5 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_version.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "13.0.0b1" +VERSION = "13.0.0b2" diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_tables_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_tables_operations.py index 27b39882bffc..97ad0c79daf5 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_tables_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_tables_operations.py @@ -22,7 +22,7 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._tables_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_workspace_request, build_update_request_initial +from ...operations._tables_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_workspace_request, build_migrate_request, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -526,3 +526,56 @@ def get_long_running_output(pipeline_response): return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}'} # type: ignore + + @distributed_trace_async + async def migrate( + self, + resource_group_name: str, + workspace_name: str, + table_name: str, + **kwargs: Any + ) -> None: + """Migrate a Log Analytics table from support of the Data Collector API and Custom Fields features + to support of Data Collection Rule-based Custom Logs. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param workspace_name: The name of the workspace. + :type workspace_name: str + :param table_name: The name of the table. + :type table_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_migrate_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + workspace_name=workspace_name, + table_name=table_name, + template_url=self.migrate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + migrate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}/migrate'} # type: ignore + diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/_log_analytics_management_client_enums.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/_log_analytics_management_client_enums.py index ff4545f03cdc..65a784c72eeb 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/_log_analytics_management_client_enums.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/_log_analytics_management_client_enums.py @@ -245,12 +245,12 @@ class StorageInsightState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ERROR = "ERROR" class TablePlanEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The table plan. + """Instruct the system how to handle and charge the logs ingested to this table. """ - #: Basic - logs that are adjusted to support high volume / low value verbose logs. + #: Logs that are adjusted to support high volume low value verbose logs. BASIC = "Basic" - #: Analytics - logs that allow monitoring and analytics. + #: Logs that allow monitoring and analytics. ANALYTICS = "Analytics" class TableSubTypeEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/_models_py3.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/_models_py3.py index 129e44635047..dc180fd51d1f 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/_models_py3.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/_models_py3.py @@ -1715,8 +1715,6 @@ def __init__( class RestoredLogs(msrest.serialization.Model): """Restore parameters. - Variables are only populated by the server, and will be ignored when sending a request. - :ivar start_restore_time: The timestamp to start the restore from (UTC). :vartype start_restore_time: ~datetime.datetime :ivar end_restore_time: The timestamp to end the restore by (UTC). @@ -1725,10 +1723,6 @@ class RestoredLogs(msrest.serialization.Model): :vartype source_table: str """ - _validation = { - 'source_table': {'readonly': True}, - } - _attribute_map = { 'start_restore_time': {'key': 'startRestoreTime', 'type': 'iso-8601'}, 'end_restore_time': {'key': 'endRestoreTime', 'type': 'iso-8601'}, @@ -1740,6 +1734,7 @@ def __init__( *, start_restore_time: Optional[datetime.datetime] = None, end_restore_time: Optional[datetime.datetime] = None, + source_table: Optional[str] = None, **kwargs ): """ @@ -1747,11 +1742,13 @@ def __init__( :paramtype start_restore_time: ~datetime.datetime :keyword end_restore_time: The timestamp to end the restore by (UTC). :paramtype end_restore_time: ~datetime.datetime + :keyword source_table: The table to restore data from. + :paramtype source_table: str """ super(RestoredLogs, self).__init__(**kwargs) self.start_restore_time = start_restore_time self.end_restore_time = end_restore_time - self.source_table = None + self.source_table = source_table class ResultStatistics(msrest.serialization.Model): @@ -2228,7 +2225,7 @@ class SearchResults(msrest.serialization.Model): :ivar query: Search job query. :vartype query: str - :ivar description: Search results table's Description. + :ivar description: Search job Description. :vartype description: str :ivar limit: Limit the search job to return up to specified number of rows. :vartype limit: int @@ -2236,7 +2233,7 @@ class SearchResults(msrest.serialization.Model): :vartype start_search_time: ~datetime.datetime :ivar end_search_time: The timestamp to end the search by (UTC). :vartype end_search_time: ~datetime.datetime - :ivar source_table: The table to search data from. + :ivar source_table: The table used in the search job. :vartype source_table: str """ @@ -2266,7 +2263,7 @@ def __init__( """ :keyword query: Search job query. :paramtype query: str - :keyword description: Search results table's Description. + :keyword description: Search job Description. :paramtype description: str :keyword limit: Limit the search job to return up to specified number of rows. :paramtype limit: int @@ -2690,11 +2687,11 @@ class Table(ProxyResource): :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.loganalytics.models.SystemData - :ivar retention_in_days: The data table data retention in days, between 4 and 730. Setting this - property to null will default to the workspace retention. + :ivar retention_in_days: The table retention in days, between 4 and 730. Setting this property + to -1 will default to the workspace retention. :vartype retention_in_days: int - :ivar total_retention_in_days: The table data total retention in days, between 4 and 2555. - Setting this property to null will default to table retention. + :ivar total_retention_in_days: The table total retention in days, between 4 and 2555. Setting + this property to -1 will default to table retention. :vartype total_retention_in_days: int :ivar archive_retention_in_days: The table data archive retention in days. Calculated as (totalRetentionInDays-retentionInDays). @@ -2705,7 +2702,8 @@ class Table(ProxyResource): :vartype restored_logs: ~azure.mgmt.loganalytics.models.RestoredLogs :ivar result_statistics: Search job execution statistics. :vartype result_statistics: ~azure.mgmt.loganalytics.models.ResultStatistics - :ivar plan: The table plan. Possible values include: "Basic", "Analytics". + :ivar plan: Instruct the system how to handle and charge the logs ingested to this table. + Possible values include: "Basic", "Analytics". :vartype plan: str or ~azure.mgmt.loganalytics.models.TablePlanEnum :ivar last_plan_modified_date: The timestamp that table plan was last modified (UTC). :vartype last_plan_modified_date: str @@ -2759,11 +2757,11 @@ def __init__( **kwargs ): """ - :keyword retention_in_days: The data table data retention in days, between 4 and 730. Setting - this property to null will default to the workspace retention. + :keyword retention_in_days: The table retention in days, between 4 and 730. Setting this + property to -1 will default to the workspace retention. :paramtype retention_in_days: int - :keyword total_retention_in_days: The table data total retention in days, between 4 and 2555. - Setting this property to null will default to table retention. + :keyword total_retention_in_days: The table total retention in days, between 4 and 2555. + Setting this property to -1 will default to table retention. :paramtype total_retention_in_days: int :keyword search_results: Parameters of the search job that initiated this table. :paramtype search_results: ~azure.mgmt.loganalytics.models.SearchResults @@ -2771,7 +2769,8 @@ def __init__( :paramtype restored_logs: ~azure.mgmt.loganalytics.models.RestoredLogs :keyword result_statistics: Search job execution statistics. :paramtype result_statistics: ~azure.mgmt.loganalytics.models.ResultStatistics - :keyword plan: The table plan. Possible values include: "Basic", "Analytics". + :keyword plan: Instruct the system how to handle and charge the logs ingested to this table. + Possible values include: "Basic", "Analytics". :paramtype plan: str or ~azure.mgmt.loganalytics.models.TablePlanEnum :keyword schema: Table schema. :paramtype schema: ~azure.mgmt.loganalytics.models.Schema @@ -3015,6 +3014,7 @@ class Workspace(TrackedResource): 'type': {'readonly': True}, 'location': {'required': True}, 'system_data': {'readonly': True}, + 'provisioning_state': {'readonly': True}, 'customer_id': {'readonly': True}, 'created_date': {'readonly': True}, 'modified_date': {'readonly': True}, @@ -3050,7 +3050,6 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, e_tag: Optional[str] = None, - provisioning_state: Optional[Union[str, "WorkspaceEntityStatus"]] = None, sku: Optional["WorkspaceSku"] = None, retention_in_days: Optional[int] = None, workspace_capping: Optional["WorkspaceCapping"] = None, @@ -3068,9 +3067,6 @@ def __init__( :paramtype location: str :keyword e_tag: The ETag of the workspace. :paramtype e_tag: str - :keyword provisioning_state: The provisioning state of the workspace. Possible values include: - "Creating", "Succeeded", "Failed", "Canceled", "Deleting", "ProvisioningAccount", "Updating". - :paramtype provisioning_state: str or ~azure.mgmt.loganalytics.models.WorkspaceEntityStatus :keyword sku: The SKU of the workspace. :paramtype sku: ~azure.mgmt.loganalytics.models.WorkspaceSku :keyword retention_in_days: The workspace data retention in days. Allowed values are per @@ -3099,7 +3095,7 @@ def __init__( super(Workspace, self).__init__(tags=tags, location=location, **kwargs) self.system_data = None self.e_tag = e_tag - self.provisioning_state = provisioning_state + self.provisioning_state = None self.customer_id = None self.sku = sku self.retention_in_days = retention_in_days @@ -3358,6 +3354,7 @@ class WorkspacePatch(AzureEntityResource): 'name': {'readonly': True}, 'type': {'readonly': True}, 'etag': {'readonly': True}, + 'provisioning_state': {'readonly': True}, 'customer_id': {'readonly': True}, 'created_date': {'readonly': True}, 'modified_date': {'readonly': True}, @@ -3389,7 +3386,6 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - provisioning_state: Optional[Union[str, "WorkspaceEntityStatus"]] = None, sku: Optional["WorkspaceSku"] = None, retention_in_days: Optional[int] = None, workspace_capping: Optional["WorkspaceCapping"] = None, @@ -3403,9 +3399,6 @@ def __init__( """ :keyword tags: A set of tags. Resource tags. Optional. :paramtype tags: dict[str, str] - :keyword provisioning_state: The provisioning state of the workspace. Possible values include: - "Creating", "Succeeded", "Failed", "Canceled", "Deleting", "ProvisioningAccount", "Updating". - :paramtype provisioning_state: str or ~azure.mgmt.loganalytics.models.WorkspaceEntityStatus :keyword sku: The SKU of the workspace. :paramtype sku: ~azure.mgmt.loganalytics.models.WorkspaceSku :keyword retention_in_days: The workspace data retention in days. Allowed values are per @@ -3433,7 +3426,7 @@ def __init__( """ super(WorkspacePatch, self).__init__(**kwargs) self.tags = tags - self.provisioning_state = provisioning_state + self.provisioning_state = None self.customer_id = None self.sku = sku self.retention_in_days = retention_in_days diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_tables_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_tables_operations.py index 4680596bc345..92f630390a58 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_tables_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_tables_operations.py @@ -229,6 +229,43 @@ def build_delete_request_initial( **kwargs ) + +def build_migrate_request( + subscription_id: str, + resource_group_name: str, + workspace_name: str, + table_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}/migrate') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), + "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + class TablesOperations(object): """TablesOperations operations. @@ -728,3 +765,56 @@ def get_long_running_output(pipeline_response): return LROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}'} # type: ignore + + @distributed_trace + def migrate( + self, + resource_group_name: str, + workspace_name: str, + table_name: str, + **kwargs: Any + ) -> None: + """Migrate a Log Analytics table from support of the Data Collector API and Custom Fields features + to support of Data Collection Rule-based Custom Logs. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param workspace_name: The name of the workspace. + :type workspace_name: str + :param table_name: The name of the table. + :type table_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_migrate_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + workspace_name=workspace_name, + table_name=table_name, + template_url=self.migrate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + migrate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}/migrate'} # type: ignore +