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

Get rid of DataFeedOptions #19054

Merged
merged 4 commits into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion sdk/metricsadvisor/azure-ai-metricsadvisor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@

**Breaking Changes**

- Delete methods now take positional only argument as id.
- Delete methods now take positional only argument as id
- `update_subscription_key` and `update_api_key` are merged into one method `update_key`
- Removed `DataFeedOptions` and moved all its properties to the `DataFeed` model

- Deprecated:
- `HttpRequestDataFeed`
Expand Down
27 changes: 12 additions & 15 deletions sdk/metricsadvisor/azure-ai-metricsadvisor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pip install azure-ai-metricsadvisor --pre

### Prerequisites

* Python 2.7, or 3.5 or later is required to use this package.
* Python 2.7, or 3.6 or later is required to use this package.
* You need an [Azure subscription][azure_sub], and a [Metrics Advisor serivce][ma_service] to use this package.

### Authenticate the client
Expand Down Expand Up @@ -124,7 +124,6 @@ from azure.ai.metricsadvisor.models import (
DataFeedSchema,
DataFeedMetric,
DataFeedDimension,
DataFeedOptions,
DataFeedRollupSettings,
DataFeedMissingDataPointFillSettings
)
Expand Down Expand Up @@ -159,18 +158,16 @@ data_feed = client.create_data_feed(
timestamp_column="Timestamp"
),
ingestion_settings=datetime.datetime(2019, 10, 1),
options=DataFeedOptions(
data_feed_description="cost/revenue data feed",
rollup_settings=DataFeedRollupSettings(
rollup_type="AutoRollup",
rollup_method="Sum",
rollup_identification_value="__CUSTOM_SUM__"
),
missing_data_point_fill_settings=DataFeedMissingDataPointFillSettings(
fill_type="SmartFilling"
),
access_mode="Private"
)
data_feed_description="cost/revenue data feed",
rollup_settings=DataFeedRollupSettings(
rollup_type="AutoRollup",
rollup_method="Sum",
rollup_identification_value="__CUSTOM_SUM__"
),
missing_data_point_fill_settings=DataFeedMissingDataPointFillSettings(
fill_type="SmartFilling"
),
access_mode="Private"
)

return data_feed
Expand Down Expand Up @@ -463,7 +460,7 @@ hook = client.create_hook(

### Async APIs

This library includes a complete async API supported on Python 3.5+. To use it, you must
This library includes a complete async API supported on Python 3.6+. To use it, you must
first install an async transport, such as [aiohttp](https://pypi.org/project/aiohttp/).
See
[azure-core documentation][azure_core_docs]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,13 @@ def convert_to_generated_data_feed_type(
granularity,
schema,
ingestion_settings,
options
admin_emails=None,
data_feed_description=None,
missing_data_point_fill_settings=None,
rollup_settings=None,
viewer_emails=None,
access_mode=None,
action_link_template=None
):
"""Convert input to data feed generated model type

Expand All @@ -129,8 +135,19 @@ def convert_to_generated_data_feed_type(
:type schema: ~azure.ai.metricsadvisor.models.DataFeedSchema
:param ingestion_settings: The data feed ingestions settings
:type ingestion_settings: ~azure.ai.metricsadvisor.models.DataFeedIngestionSettings
:param options: Data feed options.
:type options: ~azure.ai.metricsadvisor.models.DataFeedOptions
:param list[str] admin_emails: Data feed administrator emails.
:param str data_feed_description: Data feed description.
:param missing_data_point_fill_settings: The fill missing point type and value.
:type missing_data_point_fill_settings:
~azure.ai.metricsadvisor.models.DataFeedMissingDataPointFillSettings
:param rollup_settings: The rollup settings.
:type rollup_settings:
~azure.ai.metricsadvisor.models.DataFeedRollupSettings
:param list[str] viewer_emails: Data feed viewer emails.
:param access_mode: Data feed access mode. Possible values include:
"Private", "Public". Default value: "Private".
:type access_mode: str or ~azure.ai.metricsadvisor.models.DataFeedAccessMode
:param str action_link_template: action link for alert.
:rtype: Union[AzureApplicationInsightsDataFeed, AzureBlobDataFeed, AzureCosmosDBDataFeed,
AzureDataExplorerDataFeed, AzureDataLakeStorageGen2DataFeed, AzureTableDataFeed, AzureLogAnalyticsDataFeed,
InfluxDBDataFeed, MySqlDataFeed, PostgreSqlDataFeed, SQLServerDataFeed, MongoDBDataFeed,
Expand Down Expand Up @@ -168,22 +185,22 @@ def convert_to_generated_data_feed_type(
min_retry_interval_in_seconds=ingestion_settings.ingestion_retry_delay,
start_offset_in_seconds=ingestion_settings.ingestion_start_offset,
stop_retry_after_in_seconds=ingestion_settings.stop_retry_after,
data_feed_description=options.data_feed_description if options else None,
need_rollup=DataFeedRollupType._to_generated(options.rollup_settings.rollup_type)
if options and options.rollup_settings else None,
roll_up_method=options.rollup_settings.rollup_method if options and options.rollup_settings else None,
roll_up_columns=options.rollup_settings.auto_rollup_group_by_column_names
if options and options.rollup_settings else None,
all_up_identification=options.rollup_settings.rollup_identification_value
if options and options.rollup_settings else None,
fill_missing_point_type=options.missing_data_point_fill_settings.fill_type
if options and options.missing_data_point_fill_settings else None,
fill_missing_point_value=options.missing_data_point_fill_settings.custom_fill_value
if options and options.missing_data_point_fill_settings else None,
viewers=options.viewer_emails if options else None,
view_mode=options.access_mode if options else None,
admins=options.admin_emails if options else None,
action_link_template=options.action_link_template if options else None
data_feed_description=data_feed_description,
need_rollup=DataFeedRollupType._to_generated(rollup_settings.rollup_type)
if rollup_settings else None,
roll_up_method=rollup_settings.rollup_method if rollup_settings else None,
roll_up_columns=rollup_settings.auto_rollup_group_by_column_names
if rollup_settings else None,
all_up_identification=rollup_settings.rollup_identification_value
if rollup_settings else None,
fill_missing_point_type=missing_data_point_fill_settings.fill_type
if missing_data_point_fill_settings else None,
fill_missing_point_value=missing_data_point_fill_settings.custom_fill_value
if missing_data_point_fill_settings else None,
viewers=viewer_emails,
view_mode=access_mode,
admins=admin_emails,
action_link_template=action_link_template
)

def convert_to_sub_feedback(feedback):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,19 @@ def create_data_feed(
:param ingestion_settings: The data feed ingestions settings. Can be passed as a datetime to use for the
ingestion begin time or as a DataFeedIngestionSettings object if additional configuration is needed.
:type ingestion_settings: Union[~datetime.datetime, ~azure.ai.metricsadvisor.models.DataFeedIngestionSettings]
:keyword options: Data feed options.
:paramtype options: ~azure.ai.metricsadvisor.models.DataFeedOptions
:keyword list[str] admin_emails: Data feed administrator emails.
:keyword str data_feed_description: Data feed description.
:keyword missing_data_point_fill_settings: The fill missing point type and value.
:paramtype missing_data_point_fill_settings:
~azure.ai.metricsadvisor.models.DataFeedMissingDataPointFillSettings
:keyword rollup_settings: The rollup settings.
:paramtype rollup_settings:
~azure.ai.metricsadvisor.models.DataFeedRollupSettings
:keyword list[str] viewer_emails: Data feed viewer emails.
:keyword access_mode: Data feed access mode. Possible values include:
"Private", "Public". Default value: "Private".
:paramtype access_mode: str or ~azure.ai.metricsadvisor.models.DataFeedAccessMode
:keyword str action_link_template: action link for alert.
:return: DataFeed
:rtype: ~azure.ai.metricsadvisor.models.DataFeed
:raises ~azure.core.exceptions.HttpResponseError:
Expand All @@ -311,7 +322,13 @@ def create_data_feed(
:caption: Create a data feed
"""

options = kwargs.pop("options", None)
admin_emails = kwargs.pop('admin_emails', None)
data_feed_description = kwargs.pop('data_feed_description', None)
missing_data_point_fill_settings = kwargs.pop('missing_data_point_fill_settings', None)
rollup_settings = kwargs.pop('rollup_settings', None)
viewer_emails = kwargs.pop('viewer_emails', None)
access_mode = kwargs.pop('access_mode', "Private")
action_link_template = kwargs.pop('action_link_template', None)
data_feed_type = DATA_FEED[source.data_source_type]
data_feed_detail = convert_to_generated_data_feed_type(
generated_feed_type=data_feed_type,
Expand All @@ -320,7 +337,13 @@ def create_data_feed(
granularity=granularity,
schema=schema,
ingestion_settings=ingestion_settings,
options=options
admin_emails=admin_emails,
data_feed_description=data_feed_description,
missing_data_point_fill_settings=missing_data_point_fill_settings,
rollup_settings=rollup_settings,
viewer_emails=viewer_emails,
access_mode=access_mode,
action_link_template=action_link_template
)

response_headers = self._client.create_data_feed( # type: ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,19 @@ async def create_data_feed(
:param ingestion_settings: The data feed ingestions settings. Can be passed as a datetime to use for the
ingestion begin time or as a DataFeedIngestionSettings object if additional configuration is needed.
:type ingestion_settings: Union[~datetime.datetime, ~azure.ai.metricsadvisor.models.DataFeedIngestionSettings]
:keyword options: Data feed options.
:paramtype options: ~azure.ai.metricsadvisor.models.DataFeedOptions
:keyword list[str] admin_emails: Data feed administrator emails.
:keyword str data_feed_description: Data feed description.
:keyword missing_data_point_fill_settings: The fill missing point type and value.
:paramtype missing_data_point_fill_settings:
~azure.ai.metricsadvisor.models.DataFeedMissingDataPointFillSettings
:keyword rollup_settings: The rollup settings.
:paramtype rollup_settings:
~azure.ai.metricsadvisor.models.DataFeedRollupSettings
:keyword list[str] viewer_emails: Data feed viewer emails.
:keyword access_mode: Data feed access mode. Possible values include:
"Private", "Public". Default value: "Private".
:paramtype access_mode: str or ~azure.ai.metricsadvisor.models.DataFeedAccessMode
:keyword str action_link_template: action link for alert.
:return: DataFeed
:rtype: ~azure.ai.metricsadvisor.models.DataFeed
:raises ~azure.core.exceptions.HttpResponseError:
Expand All @@ -210,7 +221,13 @@ async def create_data_feed(
:caption: Create a data feed
"""

options = kwargs.pop("options", None)
admin_emails = kwargs.pop('admin_emails', None)
data_feed_description = kwargs.pop('data_feed_description', None)
missing_data_point_fill_settings = kwargs.pop('missing_data_point_fill_settings', None)
rollup_settings = kwargs.pop('rollup_settings', None)
viewer_emails = kwargs.pop('viewer_emails', None)
access_mode = kwargs.pop('access_mode', "Private")
action_link_template = kwargs.pop('action_link_template', None)
data_feed_type = DATA_FEED[source.data_source_type]
data_feed_detail = convert_to_generated_data_feed_type(
generated_feed_type=data_feed_type,
Expand All @@ -219,7 +236,13 @@ async def create_data_feed(
granularity=granularity,
schema=schema,
ingestion_settings=ingestion_settings,
options=options
admin_emails=admin_emails,
data_feed_description=data_feed_description,
missing_data_point_fill_settings=missing_data_point_fill_settings,
rollup_settings=rollup_settings,
viewer_emails=viewer_emails,
access_mode=access_mode,
action_link_template=action_link_template
)

response_headers = await self._client.create_data_feed(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
MetricAnomalyAlertConfigurationsOperator,
DataFeedGranularity,
DataFeedIngestionSettings,
DataFeedOptions,
DataFeedMissingDataPointFillSettings,
DataFeedRollupSettings,
DataFeedSchema,
Expand Down Expand Up @@ -140,7 +139,6 @@
"DataFeedStatus",
"DataFeedGranularity",
"DataFeedIngestionSettings",
"DataFeedOptions",
"DataFeedMissingDataPointFillSettings",
"DataFeedRollupSettings",
"DataFeedSchema",
Expand Down
Loading