def sample_get_data_feed(data_feed_id): # [START get_data_feed] from azure.ai.metricsadvisor import MetricsAdvisorKeyCredential, MetricsAdvisorAdministrationClient service_endpoint = os.getenv("METRICS_ADVISOR_ENDPOINT") subscription_key = os.getenv("METRICS_ADVISOR_SUBSCRIPTION_KEY") api_key = os.getenv("METRICS_ADVISOR_API_KEY") client = MetricsAdvisorAdministrationClient(service_endpoint, MetricsAdvisorKeyCredential(subscription_key, api_key)) data_feed = client.get_data_feed(data_feed_id) print("ID: {}".format(data_feed.id)) print("Data feed name: {}".format(data_feed.name)) print("Created time: {}".format(data_feed.created_time)) print("Status: {}".format(data_feed.status)) print("Source type: {}".format(data_feed.source.data_source_type)) print("Granularity type: {}".format(data_feed.granularity.granularity_type)) print("Data feed metrics: {}".format([metric.name for metric in data_feed.schema.metrics])) print("Data feed dimensions: {}".format([dimension.name for dimension in data_feed.schema.dimensions])) print("Data feed timestamp column: {}".format(data_feed.schema.timestamp_column)) print("Ingestion data starting on: {}".format(data_feed.ingestion_settings.ingestion_begin_time)) print("Data feed description: {}".format(data_feed.options.data_feed_description)) print("Data feed rollup type: {}".format(data_feed.options.rollup_settings.rollup_type)) print("Data feed rollup method: {}".format(data_feed.options.rollup_settings.rollup_method)) print("Data feed fill setting: {}".format(data_feed.options.missing_data_point_fill_settings.fill_type)) print("Data feed access mode: {}".format(data_feed.options.access_mode))
def sample_update_data_feed(data_feed): # [START update_data_feed] from azure.ai.metricsadvisor import MetricsAdvisorKeyCredential, MetricsAdvisorAdministrationClient service_endpoint = os.getenv("METRICS_ADVISOR_ENDPOINT") subscription_key = os.getenv("METRICS_ADVISOR_SUBSCRIPTION_KEY") api_key = os.getenv("METRICS_ADVISOR_API_KEY") client = MetricsAdvisorAdministrationClient( service_endpoint, MetricsAdvisorKeyCredential(subscription_key, api_key)) # update data feed on the data feed itself or by using available keyword arguments data_feed.name = "updated name" data_feed.options.data_feed_description = "updated description for data feed" client.update_data_feed(data_feed, access_mode="Public", fill_type="CustomValue", custom_fill_value=1) updated_data_feed = client.get_data_feed(data_feed.id) print("Updated name: {}".format(updated_data_feed.name)) print("Updated description: {}".format( updated_data_feed.options.data_feed_description)) print("Updated access mode: {}".format( updated_data_feed.options.access_mode)) print("Updated fill setting, value: {}, {}".format( updated_data_feed.options.missing_data_point_fill_settings.fill_type, updated_data_feed.options.missing_data_point_fill_settings. custom_fill_value, ))
def sample_delete_data_feed(data_feed_id): # [START delete_data_feed] from azure.core.exceptions import ResourceNotFoundError from azure.ai.metricsadvisor import MetricsAdvisorKeyCredential, MetricsAdvisorAdministrationClient service_endpoint = os.getenv("METRICS_ADVISOR_ENDPOINT") subscription_key = os.getenv("METRICS_ADVISOR_SUBSCRIPTION_KEY") api_key = os.getenv("METRICS_ADVISOR_API_KEY") client = MetricsAdvisorAdministrationClient(service_endpoint, MetricsAdvisorKeyCredential(subscription_key, api_key)) client.delete_data_feed(data_feed_id) try: client.get_data_feed(data_feed_id) except ResourceNotFoundError: print("Data feed successfully deleted.")