From 2bb77597640ee3723383b5422dde5d71f0a48ff9 Mon Sep 17 00:00:00 2001 From: KarishmaGhiya Date: Wed, 6 Oct 2021 23:29:37 -0700 Subject: [PATCH] remove audience support for GA release (#18071) --- sdk/monitor/monitor-query/CHANGELOG.md | 3 +-- .../monitor-query/review/monitor-query.api.md | 3 --- sdk/monitor/monitor-query/src/logsQueryClient.ts | 13 +++++-------- sdk/monitor/monitor-query/src/metricsQueryClient.ts | 12 +++++------- .../internal/unit/logsQueryClient.unittest.spec.ts | 5 +---- 5 files changed, 12 insertions(+), 24 deletions(-) diff --git a/sdk/monitor/monitor-query/CHANGELOG.md b/sdk/monitor/monitor-query/CHANGELOG.md index 15337620adfa..d88280d0973f 100644 --- a/sdk/monitor/monitor-query/CHANGELOG.md +++ b/sdk/monitor/monitor-query/CHANGELOG.md @@ -4,7 +4,6 @@ ### Features Added -- Added `audience` property in `MetricsClientOptions` - Enabled browser support - Added different result objects `LogsQueryPartialResult`, `LogsQuerySuccessfulResult` or `LogsQueryError` based on the success scenarios for log queries. @@ -13,11 +12,11 @@ - Renamed `ErrorInfo` to `LogsErrorInfo`, which now extends the `Error` class and `code` as an additional property. Removed all the other properties. - `query` method in `LogsQueryClient` renamed to `queryWorkspace` - `query` method in `MetricsQueryClient` renamed to `queryResource` -- Renamed `credentialOptions.credentialScopes` property in `LogsQueryClientOptions` to `audience` - Renamed the status types in `LogsQueryResultStatus`. `Partial` to `PartialFailure` and `Failed` to `Failure`. - Renamed `timeGrain` in `MetricAvailability` to `granularity` - Renamed `TimeInterval` to `QueryTimeInterval` - Updated constants in `Durations` to camel-case. +- Removed `credentialOptions.credentialScopes` property in `LogsQueryClientOptions` since scopes other than default are not supported yet. - Removed `throwOnAnyError` flag from `LogsQueryOptions` and `LogsQueryBatchOptions` - Removed the error classes `BatchError` and `AggregateBatchError` - Updated `LogsQueryBatchResult` object to be a list of objects with the following possible types: diff --git a/sdk/monitor/monitor-query/review/monitor-query.api.md b/sdk/monitor/monitor-query/review/monitor-query.api.md index 398400cd0d81..9327d5c3556a 100644 --- a/sdk/monitor/monitor-query/review/monitor-query.api.md +++ b/sdk/monitor/monitor-query/review/monitor-query.api.md @@ -66,7 +66,6 @@ export class LogsQueryClient { // @public export interface LogsQueryClientOptions extends CommonClientOptions { - audience?: string; endpoint?: string; } @@ -173,7 +172,6 @@ export interface MetricNamespace { // @public export interface MetricsClientOptions extends CommonClientOptions { - audience?: string; endpoint?: string; } @@ -258,7 +256,6 @@ export interface TimeSeriesElement { metadataValues?: MetadataValue[]; } - // (No @packageDocumentation comment for this package) ``` diff --git a/sdk/monitor/monitor-query/src/logsQueryClient.ts b/sdk/monitor/monitor-query/src/logsQueryClient.ts index 05218888db02..d969d032cecd 100644 --- a/sdk/monitor/monitor-query/src/logsQueryClient.ts +++ b/sdk/monitor/monitor-query/src/logsQueryClient.ts @@ -37,13 +37,6 @@ export interface LogsQueryClientOptions extends CommonClientOptions { * The host to connect to. */ endpoint?: string; - - /** - * Gets or sets the audience to use for authentication with Azure Active Directory. - * The authentication scope will be set from this audience. - * Defaults to 'https://api.loganalytics.io/.default' - */ - audience?: string; } /** @@ -61,8 +54,12 @@ export class LogsQueryClient { constructor(tokenCredential: TokenCredential, options?: LogsQueryClientOptions) { // This client defaults to using 'https://api.loganalytics.io/' as the // host. + let scope; + if (options?.endpoint) { + scope = `${options?.endpoint}./default`; + } const credentialOptions = { - credentialScopes: options?.audience + credentialScopes: scope }; const packageDetails = `azsdk-js-monitor-query/${SDK_VERSION}`; const userAgentPrefix = diff --git a/sdk/monitor/monitor-query/src/metricsQueryClient.ts b/sdk/monitor/monitor-query/src/metricsQueryClient.ts index bf2077656b40..5df900735f4c 100644 --- a/sdk/monitor/monitor-query/src/metricsQueryClient.ts +++ b/sdk/monitor/monitor-query/src/metricsQueryClient.ts @@ -41,12 +41,6 @@ const defaultMetricsScope = "https://management.azure.com/.default"; export interface MetricsQueryClientOptions extends CommonClientOptions { /** Overrides client endpoint. */ endpoint?: string; - /** - * Gets or sets the audience to use for authentication with Azure Active Directory. - * The authentication scope will be set from this audience. - * Defaults to "https://management.azure.com/.default" - */ - audience?: string; } /** @@ -63,8 +57,12 @@ export class MetricsQueryClient { * @param options - Options for the client like controlling request retries. */ constructor(tokenCredential: TokenCredential, options?: MetricsQueryClientOptions) { + let scope; + if (options?.endpoint) { + scope = `${options?.endpoint}./default`; + } const credentialOptions = { - credentialScopes: options?.audience + credentialScopes: scope }; const packageDetails = `azsdk-js-monitor-query/${SDK_VERSION}`; const userAgentPrefix = diff --git a/sdk/monitor/monitor-query/test/internal/unit/logsQueryClient.unittest.spec.ts b/sdk/monitor/monitor-query/test/internal/unit/logsQueryClient.unittest.spec.ts index dc3aa15db757..a275d71f2965 100644 --- a/sdk/monitor/monitor-query/test/internal/unit/logsQueryClient.unittest.spec.ts +++ b/sdk/monitor/monitor-query/test/internal/unit/logsQueryClient.unittest.spec.ts @@ -29,8 +29,7 @@ describe("LogsQueryClient unit tests", () => { }; const client = new LogsQueryClient(tokenCredential, { - endpoint: "https://customEndpoint1", - audience: "https://customscopes1/" + endpoint: "https://customEndpoint1" }); assert.equal(client["_logAnalytics"].$host, "https://customEndpoint1"); @@ -44,7 +43,5 @@ describe("LogsQueryClient unit tests", () => { message: "Shortcircuit auth exception" }); } - - assert.deepEqual(scopesPassed, ["https://customscopes1/"]); }); });