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

Create/Update methods stop calling get #16479

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 4 additions & 1 deletion sdk/metricsadvisor/azure-ai-metricsadvisor/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Release History

## 1.0.0b3 (Unreleased)
## 1.0.0b3 (2021-02-09)

**New Features**

Expand All @@ -10,6 +10,9 @@
**Breaking Changes**

- `list_dimension_values` has been renamed to `list_anomaly_dimension_values`
- create methods now return id instead of entire object
- update methods now return None
- Updated DataFeed.metric_ids to be a dict rather than a list

## 1.0.0b2 (2020-11-10)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def create_alert_configuration(
metric_alert_configurations, # type: List[MetricAlertConfiguration]
hook_ids, # type: List[str]
**kwargs # type: Any
): # type: (...) -> AnomalyAlertConfiguration
): # type: (...) -> str
"""Create an anomaly alert configuration.

:param str name: Name for the anomaly alert configuration.
Expand All @@ -242,8 +242,8 @@ def create_alert_configuration(
:paramtype cross_metrics_operator: str or
~azure.ai.metricsadvisor.models.MetricAnomalyAlertConfigurationsOperator
:keyword str description: Anomaly alert configuration description.
:return: AnomalyAlertConfiguration
:rtype: ~azure.ai.metricsadvisor.models.AnomalyAlertConfiguration
:return: Anomaly alert configuration unique id.
:rtype: str
:raises ~azure.core.exceptions.HttpResponseError:

.. admonition:: Example:
Expand Down Expand Up @@ -272,7 +272,7 @@ def create_alert_configuration(
)

config_id = response_headers["Location"].split("configurations/")[1]
return self.get_alert_configuration(config_id)
return config_id

@distributed_trace
def create_data_feed(
Expand All @@ -282,7 +282,7 @@ def create_data_feed(
schema, # type: Union[List[str], DataFeedSchema]
ingestion_settings, # type: Union[datetime.datetime, DataFeedIngestionSettings]
**kwargs # type: Any
): # type: (...) -> DataFeed
): # type: (...) -> str
"""Create a new data feed.

:param str name: Name for the data feed.
Expand All @@ -302,8 +302,8 @@ def create_data_feed(
:type ingestion_settings: Union[~datetime.datetime, ~azure.ai.metricsadvisor.models.DataFeedIngestionSettings]
:keyword options: Data feed options.
:paramtype options: ~azure.ai.metricsadvisor.models.DataFeedOptions
:return: DataFeed
:rtype: ~azure.ai.metricsadvisor.models.DataFeed
:return: Data feed unique id.
:rtype: str
:raises ~azure.core.exceptions.HttpResponseError:

.. admonition:: Example:
Expand Down Expand Up @@ -334,22 +334,20 @@ def create_data_feed(
**kwargs
)
data_feed_id = response_headers["Location"].split("dataFeeds/")[1]
return self.get_data_feed(data_feed_id)
return data_feed_id

@distributed_trace
def create_hook(
self, hook, # type: Union[EmailNotificationHook, WebNotificationHook]
**kwargs # type: Any
): # type: (...) -> Union[NotificationHook, EmailNotificationHook, WebNotificationHook]
): # type: (...) -> str
"""Create a new email or web hook.

:param hook: An email or web hook to create
:type hook: Union[~azure.ai.metricsadvisor.models.EmailNotificationHook,
~azure.ai.metricsadvisor.models.WebNotificationHook]
:return: EmailNotificationHook or WebNotificationHook
:rtype: Union[~azure.ai.metricsadvisor.models.NotificationHook,
~azure.ai.metricsadvisor.models.EmailNotificationHook,
~azure.ai.metricsadvisor.models.WebNotificationHook]
:return: Hook unique id.
:rtype: str
:raises ~azure.core.exceptions.HttpResponseError:

.. admonition:: Example:
Expand All @@ -375,15 +373,15 @@ def create_hook(
**kwargs
)
hook_id = response_headers["Location"].split("hooks/")[1]
return self.get_hook(hook_id)
return hook_id

@distributed_trace
def create_detection_configuration(
self, name, # type: str
metric_id, # type: str
whole_series_detection_condition, # type: MetricDetectionCondition
**kwargs # type: Any
): # type: (...) -> AnomalyDetectionConfiguration
): # type: (...) -> str
"""Create anomaly detection configuration.

:param str name: The name for the anomaly detection configuration
Expand All @@ -398,8 +396,8 @@ def create_detection_configuration(
:keyword series_detection_conditions: detection configuration for specific series.
:paramtype series_detection_conditions:
list[~azure.ai.metricsadvisor.models.MetricSingleSeriesDetectionCondition]
:return: AnomalyDetectionConfiguration
:rtype: ~azure.ai.metricsadvisor.models.AnomalyDetectionConfiguration
:return: Anomaly detection configuration unique id.
:rtype: str
:raises ~azure.core.exceptions.HttpResponseError:

.. admonition:: Example:
Expand Down Expand Up @@ -434,7 +432,7 @@ def create_detection_configuration(
**kwargs
)
config_id = response_headers["Location"].split("configurations/")[1]
return self.get_detection_configuration(config_id)
return config_id

@distributed_trace
def get_data_feed(self, data_feed_id, **kwargs):
Expand Down Expand Up @@ -708,7 +706,7 @@ def delete_hook(self, hook_id, **kwargs):
def update_data_feed(
self, data_feed, # type: Union[str, DataFeed]
**kwargs # type: Any
): # type: (...) -> DataFeed
): # type: (...) -> None
"""Update a data feed. Either pass the entire DataFeed object with the chosen updates
or the ID to your data feed with updates passed via keyword arguments. If you pass both
the DataFeed object and keyword arguments, the keyword arguments will take precedence.
Expand Down Expand Up @@ -754,8 +752,6 @@ def update_data_feed(
AzureDataExplorerDataFeed, AzureDataLakeStorageGen2DataFeed, AzureTableDataFeed, HttpRequestDataFeed,
InfluxDBDataFeed, MySqlDataFeed, PostgreSqlDataFeed, SQLServerDataFeed, MongoDBDataFeed,
ElasticsearchDataFeed]
:return: DataFeed
:rtype: ~azure.ai.metricsadvisor.models.DataFeed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should still have the rtype in the docstrings for the update methods:

:rtype: None

:raises ~azure.core.exceptions.HttpResponseError:

.. admonition:: Example:
Expand Down Expand Up @@ -802,16 +798,15 @@ def update_data_feed(
data_feed_patch_type = DATA_FEED_PATCH[data_feed.source.data_source_type]
data_feed_patch = data_feed._to_generated_patch(data_feed_patch_type, update)

self._client.update_data_feed(data_feed_id, data_feed_patch, **kwargs)
return self.get_data_feed(data_feed_id)
return self._client.update_data_feed(data_feed_id, data_feed_patch, **kwargs)

@distributed_trace
def update_alert_configuration(
self,
alert_configuration, # type: Union[str, AnomalyAlertConfiguration]
**kwargs # type: Any
):
# type: (...) -> AnomalyAlertConfiguration
# type: (...) -> None
"""Update anomaly alerting configuration. Either pass the entire AnomalyAlertConfiguration object
with the chosen updates or the ID to your alert configuration with updates passed via keyword arguments.
If you pass both the AnomalyAlertConfiguration object and keyword arguments, the keyword arguments
Expand All @@ -828,8 +823,6 @@ def update_alert_configuration(
:paramtype cross_metrics_operator: str or
~azure.ai.metricsadvisor.models.MetricAnomalyAlertConfigurationsOperator
:keyword str description: Anomaly alert configuration description.
:return: AnomalyAlertConfiguration
:rtype: ~azure.ai.metricsadvisor.models.AnomalyAlertConfiguration
:raises ~azure.core.exceptions.HttpResponseError:

.. admonition:: Example:
Expand Down Expand Up @@ -865,20 +858,19 @@ def update_alert_configuration(
description=update.pop("description", None),
)

self._client.update_anomaly_alerting_configuration(
return self._client.update_anomaly_alerting_configuration(
alert_configuration_id,
alert_configuration_patch,
**kwargs
)
return self.get_alert_configuration(alert_configuration_id)

@distributed_trace
def update_detection_configuration(
self,
detection_configuration, # type: Union[str, AnomalyDetectionConfiguration]
**kwargs # type: Any
):
# type: (...) -> AnomalyDetectionConfiguration
# type: (...) -> None
"""Update anomaly metric detection configuration. Either pass the entire AnomalyDetectionConfiguration object
with the chosen updates or the ID to your detection configuration with updates passed via keyword arguments.
If you pass both the AnomalyDetectionConfiguration object and keyword arguments, the keyword arguments
Expand All @@ -899,8 +891,6 @@ def update_detection_configuration(
:keyword series_detection_conditions: detection configuration for specific series.
:paramtype series_detection_conditions:
list[~azure.ai.metricsadvisor.models.MetricSingleSeriesDetectionCondition]
:return: AnomalyDetectionConfiguration
:rtype: ~azure.ai.metricsadvisor.models.AnomalyDetectionConfiguration
:raises ~azure.core.exceptions.HttpResponseError:

.. admonition:: Example:
Expand Down Expand Up @@ -936,20 +926,19 @@ def update_detection_configuration(
series_detection_conditions=update.pop("seriesOverrideConfigurations", None)
)

self._client.update_anomaly_detection_configuration(
return self._client.update_anomaly_detection_configuration(
detection_configuration_id,
detection_config_patch,
**kwargs
)
return self.get_detection_configuration(detection_configuration_id)

@distributed_trace
def update_hook(
self,
hook, # type: Union[str, EmailNotificationHook, WebNotificationHook]
**kwargs # type: Any
):
# type: (...) -> Union[NotificationHook, EmailNotificationHook, WebNotificationHook]
# type: (...) -> None
"""Update a hook. Either pass the entire EmailNotificationHook or WebNotificationHook object with the chosen
updates, or the ID to your hook configuration with the updates passed via keyword arguments.
If you pass both the hook object and keyword arguments, the keyword arguments will take precedence.
Expand All @@ -970,10 +959,6 @@ def update_hook(
:keyword str certificate_key: client certificate. Only should be passed to update WebNotificationHook.
:keyword str certificate_password: client certificate password. Only should be passed to update
WebNotificationHook.
:return: EmailNotificationHook or WebNotificationHook
:rtype: Union[~azure.ai.metricsadvisor.models.NotificationHook,
~azure.ai.metricsadvisor.models.EmailNotificationHook,
~azure.ai.metricsadvisor.models.WebNotificationHook]
:raises ~azure.core.exceptions.HttpResponseError:

.. admonition:: Example:
Expand Down Expand Up @@ -1032,12 +1017,11 @@ def update_hook(
certificate_password=update.pop("certificatePassword", None)
)

self._client.update_hook(
return self._client.update_hook(
hook_id,
hook_patch,
**kwargs
)
return self.get_hook(hook_id)

@distributed_trace
def list_hooks(
Expand Down
Loading