From 476e89edc38dfc430314daa2e830577c72883fc1 Mon Sep 17 00:00:00 2001 From: Jonathan Cardenas Date: Thu, 17 Mar 2022 15:36:25 -0700 Subject: [PATCH 1/4] Add dependency and autorest flag --- sdk/metricsadvisor/ai-metrics-advisor/package.json | 1 + sdk/metricsadvisor/ai-metrics-advisor/swagger/README.md | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sdk/metricsadvisor/ai-metrics-advisor/package.json b/sdk/metricsadvisor/ai-metrics-advisor/package.json index 683d70fcd882..0a63a95cca32 100644 --- a/sdk/metricsadvisor/ai-metrics-advisor/package.json +++ b/sdk/metricsadvisor/ai-metrics-advisor/package.json @@ -85,6 +85,7 @@ "@azure/core-client": "^1.0.0", "@azure/core-rest-pipeline": "^1.1.0", "@azure/core-tracing": "1.0.0-preview.13", + "@azure/core-http-compat": "^1.1.0", "@azure/logger": "^1.0.0", "tslib": "^2.2.0" }, diff --git a/sdk/metricsadvisor/ai-metrics-advisor/swagger/README.md b/sdk/metricsadvisor/ai-metrics-advisor/swagger/README.md index 8c44d5e10dfa..894aa610a056 100644 --- a/sdk/metricsadvisor/ai-metrics-advisor/swagger/README.md +++ b/sdk/metricsadvisor/ai-metrics-advisor/swagger/README.md @@ -18,11 +18,12 @@ input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/08f5e39 add-credentials: false override-client-name: GeneratedClient use-extension: - "@autorest/typescript": "6.0.0-beta.15" + "@autorest/typescript": "6.0.0-beta.16" disable-async-iterators: true hide-clients: true package-version: 1.0.1 typescript: true +core-http-compat-mode: true ``` ## Customizations for Track 2 Generator From 8d776193f68c592665784aeaa45fafa118d6ad3b Mon Sep 17 00:00:00 2001 From: Jonathan Cardenas Date: Thu, 17 Mar 2022 15:36:39 -0700 Subject: [PATCH 2/4] Generate client --- .../src/generated/generatedClient.ts | 36 +++++++++++++++++-- .../ai-metrics-advisor/src/generated/index.ts | 1 - .../src/generated/models/index.ts | 3 +- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/sdk/metricsadvisor/ai-metrics-advisor/src/generated/generatedClient.ts b/sdk/metricsadvisor/ai-metrics-advisor/src/generated/generatedClient.ts index c446a7dbb324..c5066661fea5 100644 --- a/sdk/metricsadvisor/ai-metrics-advisor/src/generated/generatedClient.ts +++ b/sdk/metricsadvisor/ai-metrics-advisor/src/generated/generatedClient.ts @@ -7,9 +7,9 @@ */ import * as coreClient from "@azure/core-client"; +import * as coreHttpCompat from "@azure/core-http-compat"; import * as Parameters from "./models/parameters"; import * as Mappers from "./models/mappers"; -import { GeneratedClientContext } from "./generatedClientContext"; import { GeneratedClientOptionalParams, GetActiveSeriesCountOptionalParams, @@ -156,7 +156,9 @@ import { } from "./models"; /** @internal */ -export class GeneratedClient extends GeneratedClientContext { +export class GeneratedClient extends coreHttpCompat.ExtendedServiceClient { + endpoint: string; + /** * Initializes a new instance of the GeneratedClient class. * @param endpoint Supported Cognitive Services endpoints (protocol and hostname, for example: @@ -164,7 +166,35 @@ export class GeneratedClient extends GeneratedClientContext { * @param options The parameter options */ constructor(endpoint: string, options?: GeneratedClientOptionalParams) { - super(endpoint, options); + if (endpoint === undefined) { + throw new Error("'endpoint' cannot be null"); + } + + // Initializing default values for options + if (!options) { + options = {}; + } + const defaults: GeneratedClientOptionalParams = { + requestContentType: "application/json; charset=utf-8" + }; + + const packageDetails = `azsdk-js-ai-metrics-advisor/1.0.1`; + const userAgentPrefix = + options.userAgentOptions && options.userAgentOptions.userAgentPrefix + ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` + : `${packageDetails}`; + + const optionsWithDefaults = { + ...defaults, + ...options, + userAgentOptions: { + userAgentPrefix + }, + baseUri: options.endpoint || "{endpoint}/metricsadvisor/v1.0" + }; + super(optionsWithDefaults); + // Parameter assignments + this.endpoint = endpoint; } /** diff --git a/sdk/metricsadvisor/ai-metrics-advisor/src/generated/index.ts b/sdk/metricsadvisor/ai-metrics-advisor/src/generated/index.ts index 3aebf3c9a56c..657fb6d642e1 100644 --- a/sdk/metricsadvisor/ai-metrics-advisor/src/generated/index.ts +++ b/sdk/metricsadvisor/ai-metrics-advisor/src/generated/index.ts @@ -8,4 +8,3 @@ export * from "./models"; export { GeneratedClient } from "./generatedClient"; -export { GeneratedClientContext } from "./generatedClientContext"; diff --git a/sdk/metricsadvisor/ai-metrics-advisor/src/generated/models/index.ts b/sdk/metricsadvisor/ai-metrics-advisor/src/generated/models/index.ts index 54175a9bd500..c34252d3b823 100644 --- a/sdk/metricsadvisor/ai-metrics-advisor/src/generated/models/index.ts +++ b/sdk/metricsadvisor/ai-metrics-advisor/src/generated/models/index.ts @@ -7,6 +7,7 @@ */ import * as coreClient from "@azure/core-client"; +import * as coreHttpCompat from "@azure/core-http-compat"; export type DataSourceCredentialUnion = | DataSourceCredential @@ -2445,7 +2446,7 @@ export type GetAnomalyDetectionConfigurationsByMetricNextResponse = AnomalyDetec /** Optional parameters. */ export interface GeneratedClientOptionalParams - extends coreClient.ServiceClientOptions { + extends coreHttpCompat.ExtendedServiceClientOptions { /** Overrides client endpoint. */ endpoint?: string; } From 587536a5fb111c70b854465e2f6e117ff7a96542 Mon Sep 17 00:00:00 2001 From: Jonathan Cardenas Date: Thu, 17 Mar 2022 15:36:59 -0700 Subject: [PATCH 3/4] Use ExtendedCommonClientOptions --- .../ai-metrics-advisor/review/ai-metrics-advisor.api.md | 6 +++--- .../src/metricsAdvisorAdministrationClient.ts | 5 +++-- .../ai-metrics-advisor/src/metricsAdvisorClient.ts | 5 +++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/sdk/metricsadvisor/ai-metrics-advisor/review/ai-metrics-advisor.api.md b/sdk/metricsadvisor/ai-metrics-advisor/review/ai-metrics-advisor.api.md index e464ae166597..d50e87c9819b 100644 --- a/sdk/metricsadvisor/ai-metrics-advisor/review/ai-metrics-advisor.api.md +++ b/sdk/metricsadvisor/ai-metrics-advisor/review/ai-metrics-advisor.api.md @@ -6,7 +6,7 @@ /// -import { CommonClientOptions } from '@azure/core-client'; +import { ExtendedCommonClientOptions } from '@azure/core-http-compat'; import { FullOperationResponse } from '@azure/core-client'; import { OperationOptions } from '@azure/core-client'; import { PagedAsyncIterableIterator } from '@azure/core-paging'; @@ -885,7 +885,7 @@ export class MetricsAdvisorAdministrationClient { } // @public -export interface MetricsAdvisorAdministrationClientOptions extends CommonClientOptions { +export interface MetricsAdvisorAdministrationClientOptions extends ExtendedCommonClientOptions { } // @public @@ -910,7 +910,7 @@ export class MetricsAdvisorClient { } // @public -export interface MetricsAdvisorClientOptions extends CommonClientOptions { +export interface MetricsAdvisorClientOptions extends ExtendedCommonClientOptions { } // @public diff --git a/sdk/metricsadvisor/ai-metrics-advisor/src/metricsAdvisorAdministrationClient.ts b/sdk/metricsadvisor/ai-metrics-advisor/src/metricsAdvisorAdministrationClient.ts index e7179d740df8..3cd97651e473 100644 --- a/sdk/metricsadvisor/ai-metrics-advisor/src/metricsAdvisorAdministrationClient.ts +++ b/sdk/metricsadvisor/ai-metrics-advisor/src/metricsAdvisorAdministrationClient.ts @@ -7,7 +7,7 @@ import { bearerTokenAuthenticationPolicy, InternalPipelineOptions, } from "@azure/core-rest-pipeline"; -import { FullOperationResponse, OperationOptions, CommonClientOptions } from "@azure/core-client"; +import { FullOperationResponse, OperationOptions } from "@azure/core-client"; import { isTokenCredential, TokenCredential } from "@azure/core-auth"; import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; import "@azure/core-paging"; @@ -68,11 +68,12 @@ import { MetricsAdvisorLoggingAllowedHeaderNames, MetricsAdvisorLoggingAllowedQueryParameters, } from "./constants"; +import { ExtendedCommonClientOptions } from "@azure/core-http-compat"; /** * Client options used to configure API requests. */ -export interface MetricsAdvisorAdministrationClientOptions extends CommonClientOptions {} +export interface MetricsAdvisorAdministrationClientOptions extends ExtendedCommonClientOptions {} /** * Options for listing data feed ingestion status diff --git a/sdk/metricsadvisor/ai-metrics-advisor/src/metricsAdvisorClient.ts b/sdk/metricsadvisor/ai-metrics-advisor/src/metricsAdvisorClient.ts index 72e51920f04f..a9d2ec81cf24 100644 --- a/sdk/metricsadvisor/ai-metrics-advisor/src/metricsAdvisorClient.ts +++ b/sdk/metricsadvisor/ai-metrics-advisor/src/metricsAdvisorClient.ts @@ -7,9 +7,10 @@ import { bearerTokenAuthenticationPolicy, InternalPipelineOptions, } from "@azure/core-rest-pipeline"; -import { OperationOptions, CommonClientOptions } from "@azure/core-client"; import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; import { isTokenCredential, TokenCredential } from "@azure/core-auth"; +import { OperationOptions } from "@azure/core-client"; +import { ExtendedCommonClientOptions } from "@azure/core-http-compat"; import { GeneratedClient } from "./generated/generatedClient"; import { createSpan } from "./tracing"; import { @@ -49,7 +50,7 @@ import { logger } from "./logger"; /** * Client options used to configure Metrics Advisor API requests. */ -export interface MetricsAdvisorClientOptions extends CommonClientOptions {} +export interface MetricsAdvisorClientOptions extends ExtendedCommonClientOptions {} /** * Options for listing incidents for detection configurations From 1b992d38ac1220892d2239686fd549a24c0c5e7c Mon Sep 17 00:00:00 2001 From: Jonathan Cardenas Date: Tue, 29 Mar 2022 15:40:14 -0700 Subject: [PATCH 4/4] Update core-http-compat to latest version --- sdk/metricsadvisor/ai-metrics-advisor/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/metricsadvisor/ai-metrics-advisor/package.json b/sdk/metricsadvisor/ai-metrics-advisor/package.json index 0a63a95cca32..b8692c3c75a9 100644 --- a/sdk/metricsadvisor/ai-metrics-advisor/package.json +++ b/sdk/metricsadvisor/ai-metrics-advisor/package.json @@ -85,7 +85,7 @@ "@azure/core-client": "^1.0.0", "@azure/core-rest-pipeline": "^1.1.0", "@azure/core-tracing": "1.0.0-preview.13", - "@azure/core-http-compat": "^1.1.0", + "@azure/core-http-compat": "^1.2.0", "@azure/logger": "^1.0.0", "tslib": "^2.2.0" },