Skip to content

Commit

Permalink
[metricsadvisor] Fix docstring formatting and resolve sphinx errors (#…
Browse files Browse the repository at this point in the history
…14144)

* docstring formatting for clients

* fix docstring formatting for models
  • Loading branch information
kristapratico authored Sep 30, 2020
1 parent 21d7d12 commit 82e6145
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 145 deletions.
17 changes: 5 additions & 12 deletions sdk/metricsadvisor/azure-ai-metricsadvisor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ pip install azure-ai-metricsadvisor --pre

You will need two keys to authenticate the client:

The subscription key to your Metrics Advisor resource. You can find this in the Keys and Endpoint section of your resource in the Azure portal.
The API key for your Metrics Advisor instance. You can find this in the web portal for Metrics Advisor, in API keys on the left navigation menu.
1) The subscription key to your Metrics Advisor resource. You can find this in the Keys and Endpoint section of your resource in the Azure portal.
2) The API key for your Metrics Advisor instance. You can find this in the web portal for Metrics Advisor, in API keys on the left navigation menu.

We can use the keys to create a new `MetricsAdvisorClient` or `MetricsAdvisorAdministrationClient`.

Expand Down Expand Up @@ -54,7 +54,7 @@ A `DataFeed` is what Metrics Advisor ingests from your data source, such as Cosm

- timestamps
- zero or more dimensions
- one or more measures.
- one or more measures

### Metric

Expand Down Expand Up @@ -313,6 +313,7 @@ from azure.ai.metricsadvisor import MetricsAdvisorKeyCredential, MetricsAdvisorC
service_endpoint = os.getenv("METRICS_ADVISOR_ENDPOINT")
subscription_key = os.getenv("METRICS_ADVISOR_SUBSCRIPTION_KEY")
api_key = os.getenv("METRICS_ADVISOR_API_KEY")
alert_id = os.getenv("METRICS_ADVISOR_ALERT_ID")

client = MetricsAdvisorClient(service_endpoint,
MetricsAdvisorKeyCredential(subscription_key, api_key)
Expand All @@ -328,15 +329,6 @@ for result in results:
print("Alert id: {}".format(result.id))
print("Create on: {}".format(result.created_on))

service_endpoint = os.getenv("METRICS_ADVISOR_ENDPOINT")
subscription_key = os.getenv("METRICS_ADVISOR_SUBSCRIPTION_KEY")
api_key = os.getenv("METRICS_ADVISOR_API_KEY")
alert_id = os.getenv("METRICS_ADVISOR_ALERT_ID")

client = MetricsAdvisorClient(service_endpoint,
MetricsAdvisorKeyCredential(subscription_key, api_key)
)

results = client.list_anomalies_for_alert(
alert_configuration_id=alert_config_id,
alert_id=alert_id,
Expand Down Expand Up @@ -433,6 +425,7 @@ additional questions or comments.
[package]: https://aka.ms/azsdk/python/metricsadvisor/pypi
[ma_service]: https://go.microsoft.com/fwlink/?linkid=2142156
[python_logging]: https://docs.python.org/3.5/library/logging.html
[azure_core]: https://aka.ms/azsdk/python/core/docs#module-azure.core.exceptions

[cla]: https://cla.microsoft.com
[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ def create_metric_anomaly_detection_configuration(
:param str name: The name for the anomaly detection configuration
:param str metric_id: Required. metric unique id.
:param whole_series_detection_condition: Required.
Conditions to detect anomalies in all time series of a metric.
:type whole_series_detection_condition: ~azure.ai.metricsadvisor.models.MetricDetectionCondition
:keyword str description: anomaly detection configuration description.
:keyword series_group_detection_conditions: detection configuration for series group.
Expand Down Expand Up @@ -408,7 +409,7 @@ def get_data_feed(self, data_feed_id, **kwargs):
:param data_feed_id: The data feed unique id.
:type data_feed_id: str
:return: DataFeed
:rtype: azure.ai.metricsadvisor.models.DataFeed
:rtype: ~azure.ai.metricsadvisor.models.DataFeed
:raises ~azure.core.exceptions.HttpResponseError:
.. admonition:: Example:
Expand Down Expand Up @@ -517,8 +518,8 @@ def get_data_feed_ingestion_progress(
:param data_feed_id: The data feed unique id.
:type data_feed_id: str
:return: DataFeedIngestionProgress, containing latest_success_timestamp
and latest_active_timestamp
:return: DataFeedIngestionProgress, containing `latest_success_timestamp`
and `latest_active_timestamp`
:rtype: ~azure.ai.metricsadvisor.models.DataFeedIngestionProgress
:raises ~azure.core.exceptions.HttpResponseError:
Expand Down Expand Up @@ -690,7 +691,7 @@ def update_data_feed(
all-up value.
:keyword rollup_type: Mark if the data feed needs rollup. Possible values include: "NoRollup",
"AutoRollup", "AlreadyRollup". Default value: "AutoRollup".
:paramtype roll_up_type: str or ~azure.ai.metricsadvisor.models.DataFeedRollupType
:paramtype rollup_type: str or ~azure.ai.metricsadvisor.models.DataFeedRollupType
:keyword list[str] auto_rollup_group_by_column_names: Roll up columns.
:keyword rollup_method: Roll up method. Possible values include: "None", "Sum", "Max", "Min",
"Avg", "Count".
Expand Down Expand Up @@ -851,6 +852,7 @@ def update_metric_anomaly_detection_configuration(
:keyword str name: The name for the anomaly detection configuration
:keyword str metric_id: metric unique id.
:keyword whole_series_detection_condition: Required.
Conditions to detect anomalies in all time series of a metric.
:paramtype whole_series_detection_condition: ~azure.ai.metricsadvisor.models.MetricDetectionCondition
:keyword str description: anomaly detection configuration description.
:keyword series_group_detection_conditions: detection configuration for series group.
Expand Down Expand Up @@ -1096,7 +1098,7 @@ def list_anomaly_alert_configurations(
:param detection_configuration_id: anomaly detection configuration unique id.
:type detection_configuration_id: str
:return: Pageable of AnomalyAlertConfiguration
:rtype: ItemPaged[AnomalyAlertConfiguration]
:rtype: ~azure.core.paging.ItemPaged[AnomalyAlertConfiguration]
:raises ~azure.core.exceptions.HttpResponseError:
.. admonition:: Example:
Expand Down Expand Up @@ -1128,7 +1130,7 @@ def list_metric_anomaly_detection_configurations(
:param metric_id: metric unique id.
:type metric_id: str
:return: Pageable of AnomalyDetectionConfiguration
:rtype: ItemPaged[AnomalyDetectionConfiguration]
:rtype: ~azure.core.paging.ItemPaged[AnomalyDetectionConfiguration]
:raises ~azure.core.exceptions.HttpResponseError:
.. admonition:: Example:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,18 @@
class MetricsAdvisorClient(object):
"""Represents an client that calls restful API of Azure Metrics Advisor service.
:param str endpoint: Url to the Azure Metrics Advisor service endpoint
:param credential: credential Used to authenticate requests to the service.
:type credential: azure.ai.metricsadvisor.MetricsAdvisorKeyCredential
:keyword Pipeline pipeline: If omitted, the standard pipeline is used.
:keyword HttpTransport transport: If omitted, the standard pipeline is used.
:keyword list[HTTPPolicy] policies: If omitted, the standard pipeline is used.
:param str endpoint: Supported Cognitive Services endpoints (protocol and hostname,
for example: https://:code:`<resource-name>`.cognitiveservices.azure.com).
:param credential: An instance of ~azure.ai.metricsadvisor.MetricsAdvisorKeyCredential.
Requires both subscription key and API key.
:type credential: ~azure.ai.metricsadvisor.MetricsAdvisorKeyCredential
:keyword Pipeline pipeline: If omitted, the standard pipeline is used.
:keyword HttpTransport transport: If omitted, the standard pipeline is used.
:keyword list[HTTPPolicy] policies: If omitted, the standard pipeline is used.
"""
def __init__(self, endpoint, credential, **kwargs):
# type: (str, MetricsAdvisorKeyCredential, dict) -> None
# type: (str, MetricsAdvisorKeyCredential, Any) -> None
try:
if not endpoint.lower().startswith('http'):
endpoint = "https://" + endpoint
Expand Down Expand Up @@ -168,11 +170,11 @@ def add_feedback(self, feedback, **kwargs):
"""Create a new metric feedback.
:param feedback: metric feedback.
:type feedback: ~azure.ai.metriscadvisor.models.AnomalyFeedback or
~azure.ai.metriscadvisor.models.ChangePointFeedback or
~azure.ai.metriscadvisor.models.CommentFeedback or
~azure.ai.metriscadvisor.models.PeriodFeedback.
:raises: ~azure.core.exceptions.HttpResponseError
:type feedback: ~azure.ai.metricsadvisor.models.AnomalyFeedback or
~azure.ai.metricsadvisor.models.ChangePointFeedback or
~azure.ai.metricsadvisor.models.CommentFeedback or
~azure.ai.metricsadvisor.models.PeriodFeedback
:raises ~azure.core.exceptions.HttpResponseError:
.. admonition:: Example:
Expand All @@ -196,11 +198,11 @@ def get_feedback(self, feedback_id, **kwargs):
:param str feedback_id: the id of the feedback.
:return: The feedback object
:rtype: ~azure.ai.metriscadvisor.models.AnomalyFeedback or
~azure.ai.metriscadvisor.models.ChangePointFeedback or
~azure.ai.metriscadvisor.models.CommentFeedback or
~azure.ai.metriscadvisor.models.PeriodFeedback.
:raises: ~azure.core.exceptions.HttpResponseError
:rtype: ~azure.ai.metricsadvisor.models.AnomalyFeedback or
~azure.ai.metricsadvisor.models.ChangePointFeedback or
~azure.ai.metricsadvisor.models.CommentFeedback or
~azure.ai.metricsadvisor.models.PeriodFeedback
:raises ~azure.core.exceptions.HttpResponseError:
.. admonition:: Example:
Expand Down Expand Up @@ -235,8 +237,9 @@ def list_feedbacks(self, metric_id, **kwargs):
"FeedbackCreatedTime".
:paramtype time_mode: str or ~azure.ai.metricsadvisor.models.FeedbackQueryTimeMode
:return: Pageable list of MetricFeedback
:rtype: ~azure.core.paging.ItemPaged[~azure.ai.metricsadvisor.models.MetricFeedback]
:raises: ~azure.core.exceptions.HttpResponseError
:rtype: ~azure.core.paging.ItemPaged[
Union[AnomalyFeedback, ChangePointFeedback, CommentFeedback, PeriodFeedback]]
:raises ~azure.core.exceptions.HttpResponseError:
.. admonition:: Example:
Expand Down Expand Up @@ -285,8 +288,8 @@ def list_incident_root_causes(self, detection_configuration_id, incident_id, **k
:param incident_id: incident id.
:type incident_id: str
:return: Pageable of root cause for incident
:rtype: ItemPaged[~azure.ai.metriscadvisor.models.IncidentRootCause]
:raises: ~azure.core.exceptions.HttpResponseError
:rtype: ~azure.core.paging.ItemPaged[~azure.ai.metricsadvisor.models.IncidentRootCause]
:raises ~azure.core.exceptions.HttpResponseError:
"""

return self._client.get_root_cause_of_incident_by_anomaly_detection_configuration( # type: ignore
Expand Down Expand Up @@ -315,8 +318,8 @@ def list_metric_enriched_series_data(
:param ~datetime.datetime start_time: start time filter under chosen time mode.
:param ~datetime.datetime end_time: end time filter under chosen time mode.
:return: Pageable of SeriesResult
:rtype: ItemPaged[~azure.ai.metricsadvisor.models.SeriesResult]
:raises: ~azure.core.exceptions.HttpResponseError
:rtype: ~azure.core.paging.ItemPaged[~azure.ai.metricsadvisor.models.SeriesResult]
:raises ~azure.core.exceptions.HttpResponseError:
"""

series_list = [
Expand Down Expand Up @@ -353,7 +356,8 @@ def list_alerts_for_alert_configuration(self, alert_configuration_id, start_time
:keyword int skip:
:return: Alerts under anomaly alert configuration.
:rtype: ~azure.core.paging.ItemPaged[~azure.ai.metricsadvisor.models.Alert]
:raises: ~azure.core.exceptions.HttpResponseError
:raises ~azure.core.exceptions.HttpResponseError:
.. admonition:: Example:
.. literalinclude:: ../samples/sample_anomaly_alert_configuration.py
Expand Down Expand Up @@ -385,14 +389,15 @@ def list_anomalies_for_alert(self, alert_configuration_id, alert_id, **kwargs):

"""Query anomalies under a specific alert.
:param alert_configuration_id: anomaly detection configuration unique id.
:param alert_configuration_id: anomaly alert configuration unique id.
:type alert_configuration_id: str
:param alert_id: alert id.
:type alert_id: str
:keyword int skip:
:return: Anomalies under a specific alert.
:rtype: ~azure.core.paging.ItemPaged[~azure.ai.metricsadvisor.models.Anomaly]
:raises: ~azure.core.exceptions.HttpResponseError
:raises ~azure.core.exceptions.HttpResponseError:
.. admonition:: Example:
.. literalinclude:: ../samples/sample_anomaly_alert_configuration.py
Expand Down Expand Up @@ -427,7 +432,7 @@ def list_anomalies_for_detection_configuration(self, detection_configuration_id,
:paramtype filter: ~azure.ai.metricsadvisor.models.DetectionAnomalyFilterCondition
:return: Anomalies under anomaly detection configuration.
:rtype: ~azure.core.paging.ItemPaged[~azure.ai.metricsadvisor.models.Anomaly]
:raises: ~azure.core.exceptions.HttpResponseError
:raises ~azure.core.exceptions.HttpResponseError:
"""

skip = kwargs.pop('skip', None)
Expand Down Expand Up @@ -463,11 +468,11 @@ def list_dimension_values_for_detection_configuration(
:param ~datetime.datetime start_time: start time filter under chosen time mode.
:param ~datetime.datetime end_time: end time filter under chosen time mode.
:keyword int skip:
:keyword dimension_name: str
:keyword str dimension_name: The dimension name to query.
:paramtype dimension_filter: ~azure.ai.metricsadvisor.models.DimensionGroupIdentity
:return: Dimension values of anomalies.
:rtype: ~azure.core.paging.ItemPaged[str]
:raises: ~azure.core.exceptions.HttpResponseError
:raises ~azure.core.exceptions.HttpResponseError:
"""

skip = kwargs.pop('skip', None)
Expand Down Expand Up @@ -497,8 +502,8 @@ def list_incidents_for_alert(self, alert_configuration_id, alert_id, **kwargs):
:type alert_id: str
:keyword int skip:
:return: Incidents under a specific alert.
:rtype: ~azure.core.paging.ItemPaged[~azure.ai.metriscadvisor.models.Incident]
:raises: ~azure.core.exceptions.HttpResponseError
:rtype: ~azure.core.paging.ItemPaged[~azure.ai.metricsadvisor.models.Incident]
:raises ~azure.core.exceptions.HttpResponseError:
"""

skip = kwargs.pop('skip', None)
Expand All @@ -523,8 +528,8 @@ def list_incidents_for_detection_configuration(self, detection_configuration_id,
:keyword filter:
:paramtype filter: ~azure.ai.metricsadvisor.models.DetectionIncidentFilterCondition
:return: Incidents under a specific alert.
:rtype: ~azure.core.paging.ItemPaged[~azure.ai.metriscadvisor.models.Incident]
:raises: ~azure.core.exceptions.HttpResponseError
:rtype: ~azure.core.paging.ItemPaged[~azure.ai.metricsadvisor.models.Incident]
:raises ~azure.core.exceptions.HttpResponseError:
"""

filter_condition = kwargs.pop('filter', None)
Expand Down Expand Up @@ -556,7 +561,7 @@ def list_metric_dimension_values(self, metric_id, dimension_name, **kwargs):
:paramtype dimension_value_filter: str
:return: Dimension from certain metric.
:rtype: ~azure.core.paging.ItemPaged[str]
:raises: ~azure.core.exceptions.HttpResponseError
:raises ~azure.core.exceptions.HttpResponseError:
"""

skip = kwargs.pop('skip', None)
Expand Down Expand Up @@ -586,8 +591,8 @@ def list_metrics_series_data(self, metric_id, start_time, end_time, series_to_fi
:param series_to_filter: query specific series.
:type series_to_filter: list[dict[str, str]]
:return: Time series data from metric.
:rtype: ItemPaged[~azure.ai.metriscadvisor.models.MetricSeriesData]
:raises: ~azure.core.exceptions.HttpResponseError
:rtype: ~azure.core.paging.ItemPaged[~azure.ai.metricsadvisor.models.MetricSeriesData]
:raises ~azure.core.exceptions.HttpResponseError:
"""

metric_data_query_options = MetricDataQueryOptions(
Expand Down Expand Up @@ -619,8 +624,8 @@ def list_metric_series_definitions(self, metric_id, active_since, **kwargs):
:keyword dimension_filter: filter specfic dimension name and values.
:paramtype dimension_filter: dict[str, list[str]]
:return: Series (dimension combinations) from metric.
:rtype: ~azure.core.paging.ItemPaged[~azure.ai.metriscadvisor.models.MetricSeriesDefinition]
:raises: ~azure.core.exceptions.HttpResponseError
:rtype: ~azure.core.paging.ItemPaged[~azure.ai.metricsadvisor.models.MetricSeriesDefinition]
:raises ~azure.core.exceptions.HttpResponseError:
"""

skip = kwargs.pop('skip', None)
Expand Down Expand Up @@ -649,8 +654,8 @@ def list_metric_enrichment_status(self, metric_id, start_time, end_time, **kwarg
:param ~datetime.datetime end_time: end time filter under chosen time mode.
:keyword int skip:
:return: Anomaly detection status.
:rtype: ~azure.core.paging.ItemPaged[~azure.ai.metriscadvisor.models.EnrichmentStatus]
:raises: ~azure.core.exceptions.HttpResponseError
:rtype: ~azure.core.paging.ItemPaged[~azure.ai.metricsadvisor.models.EnrichmentStatus]
:raises ~azure.core.exceptions.HttpResponseError:
"""

skip = kwargs.pop('skip', None)
Expand Down
Loading

0 comments on commit 82e6145

Please sign in to comment.