Skip to content

Commit

Permalink
[MetricsAdvisor] rename createTime property to createdOn (#12259)
Browse files Browse the repository at this point in the history
to be consistent with JS libraries' convention.
  • Loading branch information
jeremymeng authored Nov 6, 2020
1 parent 61d3b59 commit 6f4e75b
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 26 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 @@ -45,6 +45,7 @@
- `EnrichmentStatus.timestamp`
- `IngestionStatus.timestamp`
- `latestSuccessTimestamp` and `latestActiveTimestamp` in the return type of `getDataFeedIngestionProgress()`.
- [Breaking] property `createdTime` on `DataFeed` and `MetricFeedbackCommon` to `createdOn`.
- 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
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export type CreateDataFeedOptions = DataFeedOptions & OperationOptions;

// @public
export interface DataFeed {
createdTime: Date;
createdOn: Date;
creator: string;
granularity: DataFeedGranularity;
id: string;
Expand All @@ -212,7 +212,7 @@ export interface DataFeed {
export type DataFeedAccessMode = "Private" | "Public";

// @public
export type DataFeedDescriptor = Omit<DataFeed, "id" | "metricIds" | "isAdmin" | "status" | "creator" | "createdTime">;
export type DataFeedDescriptor = Omit<DataFeed, "id" | "metricIds" | "isAdmin" | "status" | "creator" | "createdOn">;

// @public
export type DataFeedDetailStatus = "Active" | "Paused";
Expand Down Expand Up @@ -776,7 +776,7 @@ export interface MetricEnrichmentStatusPageResponse extends Array<EnrichmentStat

// @public
export interface MetricFeedbackCommon {
readonly createdTime?: Date;
readonly createdOn?: Date;
dimensionKey: DimensionKey;
readonly id?: string;
metricId: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ async function listFeedback(client, metricId, startTime, endTime) {
});
for await (const feedback of listIterator) {
console.log(` ${feedback.feedbackType} feedback ${feedback.id}`);
console.log(` created time: ${feedback.createdTime}`);
console.log(` created time: ${feedback.createdOn}`);
console.log(` metric id: ${feedback.metricId}`);
console.log(` user principal: ${feedback.userPrincipal}`);
if (feedback.feedbackType === "Anomaly") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async function listFeedback(client: MetricsAdvisorClient, metricId: string) {
});
for await (const feedback of listIterator) {
console.log(` ${feedback.feedbackType} feedback ${feedback.id}`);
console.log(` created time: ${feedback.createdTime}`);
console.log(` created time: ${feedback.createdOn}`);
console.log(` metric id: ${feedback.metricId}`);
console.log(` user principal: ${feedback.userPrincipal}`);
if (feedback.feedbackType === "Anomaly") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export type ListDataFeedsOptions = {
*/
export type DataFeedDescriptor = Omit<
DataFeed,
"id" | "metricIds" | "isAdmin" | "status" | "creator" | "createdTime"
"id" | "metricIds" | "isAdmin" | "status" | "creator" | "createdOn"
>;

/**
Expand Down
4 changes: 2 additions & 2 deletions sdk/metricsadvisor/ai-metrics-advisor/src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export interface DataFeed {
/**
* Time when the data feed is created
*/
createdTime: Date;
createdOn: Date;
/**
* Status of the data feed.
*/
Expand Down Expand Up @@ -644,7 +644,7 @@ export interface MetricFeedbackCommon {
/**
* feedback created time
*/
readonly createdTime?: Date;
readonly createdOn?: Date;
/**
* user who gives this feedback
*/
Expand Down
4 changes: 2 additions & 2 deletions sdk/metricsadvisor/ai-metrics-advisor/src/transforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export function fromServiceMetricFeedbackUnion(
): MetricFeedbackUnion {
const common: MetricFeedbackCommon = {
id: original.feedbackId,
createdTime: original.createdTime,
createdOn: original.createdTime,
userPrincipal: original.userPrincipal,
metricId: original.metricId,
dimensionKey: original.dimensionFilter.dimension
Expand Down Expand Up @@ -337,7 +337,7 @@ export function fromServiceDataFeedDetailUnion(original: ServiceDataFeedDetailUn
id: original.dataFeedId!,
name: original.dataFeedName,
metricIds: original.metrics.map((c) => c.id!),
createdTime: original.createdTime!,
createdOn: original.createdTime!,
status: original.status!,
isAdmin: original.isAdmin!,
creator: original.creator!,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,7 @@ describe("MetricsAdvisorAdministrationClient", () => {
});

it("lists detection configurations", async function() {
const iterator = client.listDetectionConfigs(
testEnv.METRICS_ADVISOR_AZURE_BLOB_METRIC_ID_1
);
const iterator = client.listDetectionConfigs(testEnv.METRICS_ADVISOR_AZURE_BLOB_METRIC_ID_1);
let result = await iterator.next();

assert.ok(result.value.id, "Expecting first detection config");
Expand Down
25 changes: 14 additions & 11 deletions sdk/metricsadvisor/ai-metrics-advisor/test/datafeed.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -764,15 +764,15 @@ describe("MetricsAdvisorAdministrationClient datafeed", () => {
});

it("creates Unknown data feed", async () => {
const expectedSource : UnknownDataFeedSource = {
const expectedSource: UnknownDataFeedSource = {
dataSourceType: "Unknown",
dataSourceParameter: {
connectionString: "https://connect-to-postgresql",
query: "{ find: postgresql,filter: { Time: @StartTime },batch: 200 }"
}
};
try{
await client.createDataFeed({
try {
await client.createDataFeed({
name: postgreSqlFeedName,
source: expectedSource,
granularity,
Expand All @@ -781,9 +781,11 @@ describe("MetricsAdvisorAdministrationClient datafeed", () => {
options
});
assert.fail("Test should throw error");
}
catch(error){
assert.equal((error as any).message, "Cannot create a data feed with the Unknown source type.");
} catch (error) {
assert.equal(
(error as any).message,
"Cannot create a data feed with the Unknown source type."
);
}
});

Expand All @@ -798,15 +800,16 @@ describe("MetricsAdvisorAdministrationClient datafeed", () => {
}
}
};
try{
try {
await client.updateDataFeed(createdPostGreSqlId, patch);
assert.fail("Test should throw error");
}
catch(error){
assert.equal((error as any).message, "Cannot update a data feed to have the Unknown source type.");
} catch (error) {
assert.equal(
(error as any).message,
"Cannot update a data feed to have the Unknown source type."
);
}
});

});
}).timeout(60000);

Expand Down
4 changes: 2 additions & 2 deletions sdk/metricsadvisor/ai-metrics-advisor/test/transforms.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe("Transforms", () => {
const actual = fromServiceMetricFeedbackUnion(anomalyFeedback);

assert.equal(actual.id, feedbackCommon.feedbackId);
assert.equal(actual.createdTime, feedbackCommon.createdTime);
assert.equal(actual.createdOn, feedbackCommon.createdTime);
assert.equal(actual.userPrincipal, feedbackCommon.userPrincipal);
assert.equal(actual.dimensionKey, feedbackCommon.dimensionFilter.dimension);
assert.equal(actual.feedbackType, "Anomaly");
Expand Down Expand Up @@ -186,7 +186,7 @@ describe("Transforms", () => {
it("fromServiceDataFeedDetailUnion() for future data source types", () => {
const serviceDataFeed: ServiceDataFeedDetailUnion = {
dataSourceType: "Future Source" as any,
dataSourceParameter: {futureConnectionString: "xyz", futureQuery: "someQuery"} as any,
dataSourceParameter: { futureConnectionString: "xyz", futureQuery: "someQuery" } as any,
dataFeedName: "name",
metrics: [{ name: "m1", id: "m-id1", displayName: "m1 display" }],
dimension: [{ name: "d1", displayName: "d1 display" }],
Expand Down

0 comments on commit 6f4e75b

Please sign in to comment.