Skip to content
Merged
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()`.
- 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

## 1.0.0-beta.1 (2020-10-07)

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ export interface DataFeedSchema {
}

// @public
export type DataFeedSource = AzureApplicationInsightsDataFeedSource | AzureBlobDataFeedSource | AzureCosmosDBDataFeedSource | AzureDataExplorerDataFeedSource | AzureDataLakeStorageGen2DataFeedSource | AzureTableDataFeedSource | ElasticsearchDataFeedSource | HttpRequestDataFeedSource | InfluxDBDataFeedSource | MySqlDataFeedSource | PostgreSqlDataFeedSource | SQLServerDataFeedSource | MongoDBDataFeedSource;
export type DataFeedSource = AzureApplicationInsightsDataFeedSource | AzureBlobDataFeedSource | AzureCosmosDBDataFeedSource | AzureDataExplorerDataFeedSource | AzureDataLakeStorageGen2DataFeedSource | AzureTableDataFeedSource | ElasticsearchDataFeedSource | HttpRequestDataFeedSource | InfluxDBDataFeedSource | MySqlDataFeedSource | PostgreSqlDataFeedSource | SQLServerDataFeedSource | MongoDBDataFeedSource | UnknownDataFeedSource;

// @public
export type DataFeedSourcePatch = Omit<DataFeedSource, "dataSourceParameter"> & {
Expand Down Expand Up @@ -994,6 +994,12 @@ export interface TopNGroupScope {
top: number;
}

// @public
export type UnknownDataFeedSource = {
dataSourceType: "Unknown";
dataSourceParameter: unknown;
};

// @public (undocumented)
export interface WebhookHookParameter {
certificateKey?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ async function getRootCauses(client, detectionConfigId, incidentId) {
async function listAlerts(client, alertConfigId) {
console.log(`Listing alerts for alert configuration '${alertConfigId}'`);
console.log(" using for-await-of syntax");
for await (const alert of client.listAlertsForAlertConfiguration(
for await (const alert of client.listAlerts(
alertConfigId,
new Date("10/22/2020"),
new Date("10/24/2020"),
new Date("11/01/2020"),
new Date("11/05/2020"),
"AnomalyTime"
)) {
console.log(" Alert");
Expand All @@ -138,10 +138,10 @@ async function listAlerts(client, alertConfigId) {

console.log(` by pages`);
const iterator = client
.listAlertsForAlertConfiguration(
.listAlerts(
alertConfigId,
new Date("10/22/2020"),
new Date("10/24/2020"),
new Date("11/01/2020"),
new Date("11/05/2020"),
"AnomalyTime"
)
.byPage({ maxPageSize: 20 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ async function getRootCauses(
async function listAlerts(client: MetricsAdvisorClient, alertConfigId: string) {
console.log(`Listing alerts for alert configuration '${alertConfigId}'`);
console.log(" using for-await-of syntax");
for await (const alert of client.listAlertsForAlertConfiguration(
for await (const alert of client.listAlerts(
alertConfigId,
new Date("10/22/2020"),
new Date("10/24/2020"),
new Date("11/01/2020"),
new Date("11/05/2020"),
"AnomalyTime"
)) {
console.log(" Alert");
Expand All @@ -150,10 +150,10 @@ async function listAlerts(client: MetricsAdvisorClient, alertConfigId: string) {

console.log(` by pages`);
const iterator = client
.listAlertsForAlertConfiguration(
.listAlerts(
alertConfigId,
new Date("10/22/2020"),
new Date("10/24/2020"),
new Date("11/01/2020"),
new Date("11/05/2020"),
"AnomalyTime"
)
.byPage({ maxPageSize: 20 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ export class MetricsAdvisorAdministrationClient {
operationOptions
);
const { name, granularity, source, schema, ingestionSettings, options } = 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"
? "NeedRollup"
Expand Down Expand Up @@ -454,7 +456,9 @@ export class MetricsAdvisorAdministrationClient {
"MetricsAdvisorAdministrationClient-updateDataFeed",
options
);

if (patch.source.dataSourceType === "Unknown") {
throw new Error("Cannot update a data feed to have the Unknown source type.");
}
try {
const requestOptions = operationOptionsToRequestOptionsBase(finalOptions);
const patchBody = {
Expand Down
11 changes: 10 additions & 1 deletion sdk/metricsadvisor/ai-metrics-advisor/src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,14 @@ export type MongoDBDataFeedSource = {
dataSourceParameter: MongoDBParameter;
};

/**
* Represents an Unknown data source.
*/
export type UnknownDataFeedSource = {
dataSourceType: "Unknown";
dataSourceParameter: unknown;
};

/**
* Represents a SQL Server data source.
*/
Expand All @@ -425,7 +433,8 @@ export type DataFeedSource =
| MySqlDataFeedSource
| PostgreSqlDataFeedSource
| SQLServerDataFeedSource
| MongoDBDataFeedSource;
| MongoDBDataFeedSource
| UnknownDataFeedSource;

/**
* Represents the input type to the Update Data Feed operation.
Expand Down
8 changes: 7 additions & 1 deletion sdk/metricsadvisor/ai-metrics-advisor/src/transforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,13 @@ export function fromServiceDataFeedDetailUnion(original: ServiceDataFeedDetailUn
return result13;
}
default:
throw new Error(`Unrecognized datasource type ${original.dataSourceType}`);
return {
...common,
source: {
dataSourceType: "Unknown",
dataSourceParameter: (original as any).dataSourceParameter
}
};
}
}

Expand Down
10 changes: 5 additions & 5 deletions sdk/metricsadvisor/ai-metrics-advisor/test/advisorclient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,15 @@ describe("MetricsAdvisorClient", () => {
const iterator = client
.listAlerts(
testEnv.METRICS_ADVISOR_ALERT_CONFIG_ID,
new Date(Date.UTC(2020, 0, 1)),
new Date(Date.UTC(2020, 8, 12)),
new Date(Date.UTC(2020, 10, 1)),
new Date(Date.UTC(2020, 10, 5)),
"AnomalyTime"
)
.byPage({ maxPageSize: 2 });
.byPage({ maxPageSize: 1 });
let result = await iterator.next();
assert.equal(result.value.length, 2, "Expecting two alerts in first page");
assert.equal(result.value.length, 1, "Expecting one alert in first page");
result = await iterator.next();
assert.equal(result.value.length, 2, "Expecting two alerts in second page");
assert.equal(result.value.length, 1, "Expecting one alert in second page");
});

it("lists anomalies for alert", async function() {
Expand Down
Loading