Skip to content

Commit

Permalink
[MetricsAdvisor] Flatten DataFeedOptions in data feed (Azure#12263)
Browse files Browse the repository at this point in the history
and remove the wrapping `options`. We were putting into it all the
rest of optional settings that don't fit into any of groupings but
it's not necessary.
  • Loading branch information
jeremymeng authored Nov 6, 2020
1 parent 25464c7 commit e918a3e
Show file tree
Hide file tree
Showing 11 changed files with 179 additions and 202 deletions.
1 change: 1 addition & 0 deletions sdk/metricsadvisor/ai-metrics-advisor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
- `IngestionStatus.timestamp`
- `latestSuccessTimestamp` and `latestActiveTimestamp` in the return type of `getDataFeedIngestionProgress()`.
- [Breaking] property `createdTime` on `DataFeed` and `MetricFeedbackCommon` to `createdOn`.
- [Breaking] Remove the wrapping data feed `options` property from `DataFeed` and `DataFeedPatch` and flatten its child properties.
- Parameters of `Date` type now also accept strings. No validation is done for the strings. The SDK calls `new Date()` to convert them to `Date`.
- Handle potential new data feed source types gracefully

Expand Down
22 changes: 10 additions & 12 deletions sdk/metricsadvisor/ai-metrics-advisor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,18 +197,16 @@ async function createDataFeed(adminClient, sqlServerConnectionString, sqlServerQ
ingestionRetryDelayInSeconds: -1,
stopRetryAfterInSeconds: -1
},
options: {
rollupSettings: {
rollupType: "AutoRollup",
rollupMethod: "Sum",
rollupIdentificationValue: "__CUSTOM_SUM__"
},
missingDataPointFillSettings: {
fillType: "SmartFilling"
},
accessMode: "Private",
adminEmails: ["[email protected]"]
}
rollupSettings: {
rollupType: "AutoRollup",
rollupMethod: "Sum",
rollupIdentificationValue: "__CUSTOM_SUM__"
},
missingDataPointFillSettings: {
fillType: "SmartFilling"
},
accessMode: "Private",
adminEmails: ["[email protected]"]
};
const result = await adminClient.createDataFeed(dataFeed);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,19 +194,18 @@ export type ChangeThresholdConditionUnion = {
export type CreateDataFeedOptions = DataFeedOptions & OperationOptions;

// @public
export interface DataFeed {
export type DataFeed = {
id: string;
name: string;
createdOn: Date;
status: DataFeedStatus;
isAdmin: boolean;
creator: string;
source: DataFeedSource;
schema: DataFeedSchema;
granularity: DataFeedGranularity;
id: string;
ingestionSettings: DataFeedIngestionSettings;
isAdmin: boolean;
name: string;
options?: DataFeedOptions;
schema: DataFeedSchema;
source: DataFeedSource;
status: DataFeedStatus;
}
} & DataFeedOptions;

// @public
export type DataFeedAccessMode = "Private" | "Public";
Expand Down Expand Up @@ -274,17 +273,16 @@ export interface DataFeedOptions {
}

// @public
export interface DataFeedPatch {
ingestionSettings?: DataFeedIngestionSettings;
export type DataFeedPatch = {
name?: string;
options?: DataFeedOptions & {
status?: DataFeedDetailStatus;
};
source: DataFeedSourcePatch;
schema?: {
timestampColumn?: string;
};
source: DataFeedSourcePatch;
}
ingestionSettings?: DataFeedIngestionSettings;
} & DataFeedOptions & {
status?: DataFeedDetailStatus;
};

// @public
export type DataFeedRollupMethod = "None" | "Sum" | "Max" | "Min" | "Avg" | "Count";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,16 @@ async function createDataFeed(client) {
ingestionRetryDelayInSeconds: -1,
stopRetryAfterInSeconds: -1
},
options: {
rollupSettings: {
rollupType: "AutoRollup",
rollupMethod: "Sum",
rollupIdentificationValue: "__SUM__"
},
missingDataPointFillSettings: {
fillType: "CustomValue",
customFillValue: 567
},
accessMode: "Private"
}
rollupSettings: {
rollupType: "AutoRollup",
rollupMethod: "Sum",
rollupIdentificationValue: "__SUM__"
},
missingDataPointFillSettings: {
fillType: "CustomValue",
customFillValue: 567
},
accessMode: "Private"
};

const result = await client.createDataFeed(feed);
Expand Down Expand Up @@ -149,13 +147,11 @@ async function updateDataFeed(client, dataFeedId) {
stopRetryAfterInSeconds: 667777,
ingestionStartOffsetInSeconds: 4444
},
options: {
description: "New datafeed description",
missingDataPointFillSettings: {
fillType: "SmartFilling"
},
status: "Paused"
}
description: "New datafeed description",
missingDataPointFillSettings: {
fillType: "SmartFilling"
},
status: "Paused"
};

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,16 @@ async function createDataFeed(adminClient, sqlServerConnectionString, sqlServerQ
ingestionRetryDelayInSeconds: -1,
stopRetryAfterInSeconds: -1
},
options: {
rollupSettings: {
rollupType: "AutoRollup",
rollupMethod: "Sum",
rollupIdentificationValue: "__SUM__"
},
missingDataPointFillSettings: {
fillType: "SmartFilling"
},
accessMode: "Private",
adminEmails: ["[email protected]"]
}
rollupSettings: {
rollupType: "AutoRollup",
rollupMethod: "Sum",
rollupIdentificationValue: "__SUM__"
},
missingDataPointFillSettings: {
fillType: "SmartFilling"
},
accessMode: "Private",
adminEmails: ["[email protected]"]
};
const result = await adminClient.createDataFeed(dataFeed);
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,16 @@ async function createDataFeed(
ingestionRetryDelayInSeconds: -1,
stopRetryAfterInSeconds: -1
},
options: {
rollupSettings: {
rollupType: "AutoRollup",
rollupMethod: "Sum",
rollupIdentificationValue: "__CUSTOM_SUM__"
},
missingDataPointFillSettings: {
fillType: "CustomValue",
customFillValue: 567
},
accessMode: "Private"
}
rollupSettings: {
rollupType: "AutoRollup",
rollupMethod: "Sum",
rollupIdentificationValue: "__CUSTOM_SUM__"
},
missingDataPointFillSettings: {
fillType: "CustomValue",
customFillValue: 567
},
accessMode: "Private"
};
const result = await client.createDataFeed(feed);

Expand Down Expand Up @@ -155,13 +153,11 @@ async function updateDataFeed(client: MetricsAdvisorAdministrationClient, dataFe
stopRetryAfterInSeconds: 667777,
ingestionStartOffsetInSeconds: 4444
},
options: {
description: "New datafeed description",
missingDataPointFillSettings: {
fillType: "SmartFilling"
},
status: "Paused"
}
description: "New datafeed description",
missingDataPointFillSettings: {
fillType: "SmartFilling"
},
status: "Paused"
};

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,16 @@ async function createDataFeed(
ingestionRetryDelayInSeconds: -1,
stopRetryAfterInSeconds: -1
},
options: {
rollupSettings: {
rollupType: "AutoRollup",
rollupMethod: "Sum",
rollupIdentificationValue: "__SUM__"
},
missingDataPointFillSettings: {
fillType: "SmartFilling"
},
accessMode: "Private",
adminEmails: ["[email protected]"]
}
rollupSettings: {
rollupType: "AutoRollup",
rollupMethod: "Sum",
rollupIdentificationValue: "__SUM__"
},
missingDataPointFillSettings: {
fillType: "SmartFilling"
},
accessMode: "Private",
adminEmails: ["[email protected]"]
};
const result = await adminClient.createDataFeed(dataFeed);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,35 +187,46 @@ export class MetricsAdvisorAdministrationClient {
"MetricsAdvisorAdministrationClient-createDataFeed",
operationOptions
);
const { name, granularity, source, schema, ingestionSettings, options } = feed;
const {
name,
granularity,
source,
schema,
ingestionSettings,
rollupSettings,
missingDataPointFillSettings,
accessMode,
adminEmails,
viewerEmails,
description
} = feed;

if (source.dataSourceType === "Unknown") {
throw new Error("Cannot create a data feed with the Unknown source type.");
}

const needRollup: NeedRollupEnum | undefined =
options?.rollupSettings?.rollupType === "AutoRollup"
rollupSettings?.rollupType === "AutoRollup"
? "NeedRollup"
: options?.rollupSettings?.rollupType === "AlreadyRollup"
: rollupSettings?.rollupType === "AlreadyRollup"
? "AlreadyRollup"
: options?.rollupSettings?.rollupType === "NoRollup"
: rollupSettings?.rollupType === "NoRollup"
? "NoRollup"
: undefined;
const rollUpColumns: string[] | undefined =
options?.rollupSettings?.rollupType === "AutoRollup"
? options?.rollupSettings.autoRollupGroupByColumnNames
rollupSettings?.rollupType === "AutoRollup"
? rollupSettings.autoRollupGroupByColumnNames
: undefined;
const allUpIdentification: string | undefined =
options?.rollupSettings?.rollupType === "AutoRollup" ||
options?.rollupSettings?.rollupType === "AlreadyRollup"
? options?.rollupSettings.rollupIdentificationValue
rollupSettings?.rollupType === "AutoRollup" || rollupSettings?.rollupType === "AlreadyRollup"
? rollupSettings.rollupIdentificationValue
: undefined;
const rollUpMethod: DataFeedRollupMethod | undefined =
options?.rollupSettings?.rollupType === "AutoRollup"
? options?.rollupSettings.rollupMethod
: undefined;
const fillMissingPointType = options?.missingDataPointFillSettings?.fillType;
rollupSettings?.rollupType === "AutoRollup" ? rollupSettings.rollupMethod : undefined;
const fillMissingPointType = missingDataPointFillSettings?.fillType;
const fillMissingPointValue =
options?.missingDataPointFillSettings?.fillType === "CustomValue"
? options?.missingDataPointFillSettings.customFillValue
missingDataPointFillSettings?.fillType === "CustomValue"
? missingDataPointFillSettings.customFillValue
: undefined;
try {
const requestOptions = operationOptionsToRequestOptionsBase(finalOptions);
Expand All @@ -237,10 +248,10 @@ export class MetricsAdvisorAdministrationClient {
rollUpMethod,
fillMissingPointType,
fillMissingPointValue,
viewMode: options?.accessMode,
admins: options?.adminEmails,
viewers: options?.viewerEmails,
dataFeedDescription: options?.description,
viewMode: accessMode,
admins: adminEmails,
viewers: viewerEmails,
dataFeedDescription: description,
...finalOptions
};
const result = await this.client.createDataFeed(body, requestOptions);
Expand Down Expand Up @@ -467,7 +478,7 @@ export class MetricsAdvisorAdministrationClient {
dataSourceParameter: patch.source.dataSourceParameter,
// name and description
dataFeedName: patch.name,
dataFeedDescription: patch.options?.description,
dataFeedDescription: patch.description,
// schema
timestampColumn: patch.schema?.timestampColumn,
// ingestion settings
Expand All @@ -477,19 +488,19 @@ export class MetricsAdvisorAdministrationClient {
minRetryIntervalInSeconds: patch.ingestionSettings?.ingestionRetryDelayInSeconds,
stopRetryAfterInSeconds: patch.ingestionSettings?.stopRetryAfterInSeconds,
// rollup settings
...toServiceRollupSettings(patch.options?.rollupSettings),
...toServiceRollupSettings(patch.rollupSettings),
// missing point filling settings
fillMissingPointType: patch.options?.missingDataPointFillSettings?.fillType,
fillMissingPointType: patch.missingDataPointFillSettings?.fillType,
fillMissingPointValue:
patch.options?.missingDataPointFillSettings?.fillType === "CustomValue"
? patch.options.missingDataPointFillSettings.customFillValue
patch.missingDataPointFillSettings?.fillType === "CustomValue"
? patch.missingDataPointFillSettings.customFillValue
: undefined,
// other options
viewMode: patch.options?.accessMode,
admins: patch.options?.adminEmails,
viewers: patch.options?.viewerEmails,
status: patch.options?.status,
actionLinkTemplate: patch.options?.actionLinkTemplate
viewMode: patch.accessMode,
admins: patch.adminEmails,
viewers: patch.viewerEmails,
status: patch.status,
actionLinkTemplate: patch.actionLinkTemplate
};
await this.client.updateDataFeed(dataFeedId, patchBody, requestOptions);
return this.getDataFeed(dataFeedId);
Expand Down
Loading

0 comments on commit e918a3e

Please sign in to comment.