From 8b98b5a131ef48b86c50848eb9c288ec023fe51a Mon Sep 17 00:00:00 2001 From: Chenjie Shi Date: Wed, 4 Dec 2024 18:51:11 +0800 Subject: [PATCH] [tcgc] support emit code model (#1912) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: https://github.com/Azure/typespec-azure/issues/1892 There are three ways to get the code model after TCGC conversion: 1. Use TCGC as an emitter to emit the code model: tsp compile . --emit=@azure-tools/typespec-client-generator-core 2. Output the TCGC code model when used by languageā€™s emitter: set `exportTCGCoutput` to true when `createSdkContext` 3. In Azure playground, select @azure-tools/typespec-client-generator-core emitter --- .../tcgc_output-2024-10-26-15-38-13.md | 7 + .../src/main.tsx | 1 + .../typespec-client-generator-core/README.md | 59 + .../package.json | 3 +- .../src/context.ts | 122 + .../src/decorators.ts | 77 - .../src/index.ts | 1 + .../src/interfaces.ts | 1 + .../typespec-client-generator-core/src/lib.ts | 21 +- .../src/package.ts | 15 +- .../src/public-utils.ts | 11 - .../src/validate.ts | 3 +- .../test/context/create-context.test.ts | 321 ++ .../context/output/tcgc-output-complex.yaml | 4161 +++++++++++++++++ .../test/context/output/tcgc-output.yaml | 94 + .../test/decorators.test.ts | 35 - .../test/public-utils.test.ts | 55 +- .../test/test-host.ts | 212 +- .../test/types/enum-types.test.ts | 8 +- pnpm-lock.yaml | 3 + .../reference/emitter.md | 62 + .../reference/index.mdx | 4 + 22 files changed, 4989 insertions(+), 287 deletions(-) create mode 100644 .chronus/changes/tcgc_output-2024-10-26-15-38-13.md create mode 100644 packages/typespec-client-generator-core/src/context.ts create mode 100644 packages/typespec-client-generator-core/test/context/create-context.test.ts create mode 100644 packages/typespec-client-generator-core/test/context/output/tcgc-output-complex.yaml create mode 100644 packages/typespec-client-generator-core/test/context/output/tcgc-output.yaml create mode 100644 website/src/content/docs/docs/libraries/typespec-client-generator-core/reference/emitter.md diff --git a/.chronus/changes/tcgc_output-2024-10-26-15-38-13.md b/.chronus/changes/tcgc_output-2024-10-26-15-38-13.md new file mode 100644 index 0000000000..9e531fa18d --- /dev/null +++ b/.chronus/changes/tcgc_output-2024-10-26-15-38-13.md @@ -0,0 +1,7 @@ +--- +changeKind: feature +packages: + - "@azure-tools/typespec-client-generator-core" +--- + +support emit code model \ No newline at end of file diff --git a/packages/typespec-azure-playground-website/src/main.tsx b/packages/typespec-azure-playground-website/src/main.tsx index aa068b0687..5db22f0264 100644 --- a/packages/typespec-azure-playground-website/src/main.tsx +++ b/packages/typespec-azure-playground-website/src/main.tsx @@ -48,6 +48,7 @@ await renderReactPlayground({ emitterViewers: { "@typespec/openapi3": [SwaggerUIViewer], "@azure-tools/typespec-autorest": [SwaggerUIViewer], + "@azure-tools/typespec-client-generator-core": [SwaggerUIViewer], }, importConfig: { useShim: true, diff --git a/packages/typespec-client-generator-core/README.md b/packages/typespec-client-generator-core/README.md index e83afdb5bc..e426d7c655 100644 --- a/packages/typespec-client-generator-core/README.md +++ b/packages/typespec-client-generator-core/README.md @@ -8,6 +8,65 @@ TypeSpec Data Plane Generation library npm install @azure-tools/typespec-client-generator-core ``` +## Usage + +1. Via the command line + +```bash +tsp compile . --emit=@azure-tools/typespec-client-generator-core +``` + +2. Via the config + +```yaml +emit: + - "@azure-tools/typespec-client-generator-core" +``` + +The config can be extended with options as follows: + +```yaml +emit: + - "@azure-tools/typespec-client-generator-core" +options: + "@azure-tools/typespec-client-generator-core": + option: value +``` + +## Emitter options + +### `generate-protocol-methods` + +**Type:** `boolean` + +### `generate-convenience-methods` + +**Type:** `boolean` + +### `package-name` + +**Type:** `string` + +### `flatten-union-as-enum` + +**Type:** `boolean` + +### `api-version` + +**Type:** `string` + +### `examples-directory` + +**Type:** `string` + +### `examples-dir` + +**Type:** `string` + +### `emitter-name` + +**Type:** `string` + ## Decorators ### Azure.ClientGenerator.Core diff --git a/packages/typespec-client-generator-core/package.json b/packages/typespec-client-generator-core/package.json index 973a260e6d..6cab75b4d2 100644 --- a/packages/typespec-client-generator-core/package.json +++ b/packages/typespec-client-generator-core/package.json @@ -57,7 +57,8 @@ ], "dependencies": { "change-case": "~5.4.4", - "pluralize": "^8.0.0" + "pluralize": "^8.0.0", + "yaml": "~2.5.1" }, "peerDependencies": { "@azure-tools/typespec-azure-core": "workspace:~", diff --git a/packages/typespec-client-generator-core/src/context.ts b/packages/typespec-client-generator-core/src/context.ts new file mode 100644 index 0000000000..d9b20a6ecc --- /dev/null +++ b/packages/typespec-client-generator-core/src/context.ts @@ -0,0 +1,122 @@ +import { + createDiagnosticCollector, + EmitContext, + emitFile, + Program, + resolvePath, +} from "@typespec/compiler"; +import { stringify } from "yaml"; +import { defaultDecoratorsAllowList } from "./configs.js"; +import { handleClientExamples } from "./example.js"; +import { + SdkContext, + SdkEmitterOptions, + SdkHttpOperation, + SdkServiceOperation, + TCGCContext, +} from "./interfaces.js"; +import { parseEmitterName } from "./internal-utils.js"; +import { getSdkPackage } from "./package.js"; + +export function createTCGCContext(program: Program, emitterName?: string): TCGCContext { + const diagnostics = createDiagnosticCollector(); + return { + program, + emitterName: diagnostics.pipe( + parseEmitterName(program, emitterName ?? program.emitters[0]?.metadata?.name), + ), + diagnostics: diagnostics.diagnostics, + originalProgram: program, + __clientToParameters: new Map(), + __tspTypeToApiVersions: new Map(), + __clientToApiVersionClientDefaultValue: new Map(), + previewStringRegex: /-preview$/, + disableUsageAccessPropagationToBase: false, + __pagedResultSet: new Set(), + }; +} + +interface VersioningStrategy { + readonly strategy?: "ignore"; + readonly previewStringRegex?: RegExp; // regex to match preview versions +} + +export interface CreateSdkContextOptions { + readonly versioning?: VersioningStrategy; + additionalDecorators?: string[]; + disableUsageAccessPropagationToBase?: boolean; // this flag is for some languages that has no need to generate base model, but generate model with composition + exportTCGCoutput?: boolean; // this flag is for emitter to export TCGC output as yaml file +} + +export async function createSdkContext< + TOptions extends Record = SdkEmitterOptions, + TServiceOperation extends SdkServiceOperation = SdkHttpOperation, +>( + context: EmitContext, + emitterName?: string, + options?: CreateSdkContextOptions, +): Promise> { + const diagnostics = createDiagnosticCollector(); + const protocolOptions = true; // context.program.getLibraryOptions("generate-protocol-methods"); + const convenienceOptions = true; // context.program.getLibraryOptions("generate-convenience-methods"); + const generateProtocolMethods = context.options["generate-protocol-methods"] ?? protocolOptions; + const generateConvenienceMethods = + context.options["generate-convenience-methods"] ?? convenienceOptions; + const tcgcContext = createTCGCContext( + context.program, + emitterName ?? context.options["emitter-name"], + ); + const sdkContext: SdkContext = { + ...tcgcContext, + emitContext: context, + sdkPackage: undefined!, + generateProtocolMethods: generateProtocolMethods, + generateConvenienceMethods: generateConvenienceMethods, + packageName: context.options["package-name"], + flattenUnionAsEnum: context.options["flatten-union-as-enum"] ?? true, + apiVersion: options?.versioning?.strategy === "ignore" ? "all" : context.options["api-version"], + examplesDir: context.options["examples-dir"] ?? context.options["examples-directory"], + decoratorsAllowList: [...defaultDecoratorsAllowList, ...(options?.additionalDecorators ?? [])], + previewStringRegex: options?.versioning?.previewStringRegex || tcgcContext.previewStringRegex, + disableUsageAccessPropagationToBase: options?.disableUsageAccessPropagationToBase ?? false, + }; + sdkContext.sdkPackage = diagnostics.pipe(getSdkPackage(sdkContext)); + for (const client of sdkContext.sdkPackage.clients) { + diagnostics.pipe(await handleClientExamples(sdkContext, client)); + } + sdkContext.diagnostics = sdkContext.diagnostics.concat(diagnostics.diagnostics); + + if (options?.exportTCGCoutput) { + await exportTCGCOutput(sdkContext); + } + return sdkContext; +} + +async function exportTCGCOutput(context: SdkContext) { + await emitFile(context.program, { + path: resolvePath(context.emitContext.emitterOutputDir, "tcgc-output.yaml"), + content: stringify( + context.sdkPackage, + (k, v) => { + if (typeof k === "string" && k.startsWith("__")) { + return undefined; // skip keys starting with "__" from the output + } + if (k === "scheme") { + return undefined; // remove credential schema + } + if (k === "rawExample") { + return undefined; // remove raw example + } + return v; + }, + { lineWidth: 0 }, + ), + }); +} + +export async function $onEmit(context: EmitContext) { + if (!context.program.compilerOptions.noEmit) { + const sdkContext = await createSdkContext(context); + await exportTCGCOutput(sdkContext); + } +} diff --git a/packages/typespec-client-generator-core/src/decorators.ts b/packages/typespec-client-generator-core/src/decorators.ts index 287fdb15a2..0e0630ae9b 100644 --- a/packages/typespec-client-generator-core/src/decorators.ts +++ b/packages/typespec-client-generator-core/src/decorators.ts @@ -3,7 +3,6 @@ import { DecoratorContext, DecoratorExpressionNode, DecoratorFunction, - EmitContext, Enum, EnumMember, Interface, @@ -17,7 +16,6 @@ import { SyntaxKind, Type, Union, - createDiagnosticCollector, getDiscriminator, getNamespaceFullName, getProjectedName, @@ -42,20 +40,14 @@ import { ProtocolAPIDecorator, UsageDecorator, } from "../generated-defs/Azure.ClientGenerator.Core.js"; -import { defaultDecoratorsAllowList } from "./configs.js"; -import { handleClientExamples } from "./example.js"; import { AccessFlags, LanguageScopes, SdkClient, - SdkContext, - SdkEmitterOptions, - SdkHttpOperation, SdkInitializationType, SdkMethodParameter, SdkModelPropertyType, SdkOperationGroup, - SdkServiceOperation, TCGCContext, UsageFlags, } from "./interfaces.js"; @@ -66,10 +58,8 @@ import { getValidApiVersion, isAzureCoreTspModel, negationScopesKey, - parseEmitterName, } from "./internal-utils.js"; import { createStateSymbol, reportDiagnostic } from "./lib.js"; -import { getSdkPackage } from "./package.js"; import { getLibraryName } from "./public-utils.js"; import { getSdkEnum, getSdkModel, getSdkUnion } from "./types.js"; @@ -655,73 +645,6 @@ export function listOperationsInOperationGroup( return operations; } -export function createTCGCContext(program: Program, emitterName: string): TCGCContext { - const diagnostics = createDiagnosticCollector(); - return { - program, - emitterName: diagnostics.pipe(parseEmitterName(program, emitterName)), - diagnostics: diagnostics.diagnostics, - originalProgram: program, - __clientToParameters: new Map(), - __tspTypeToApiVersions: new Map(), - __clientToApiVersionClientDefaultValue: new Map(), - previewStringRegex: /-preview$/, - disableUsageAccessPropagationToBase: false, - __pagedResultSet: new Set(), - }; -} - -interface VersioningStrategy { - readonly strategy?: "ignore"; - readonly previewStringRegex?: RegExp; // regex to match preview versions -} - -export interface CreateSdkContextOptions { - readonly versioning?: VersioningStrategy; - additionalDecorators?: string[]; - disableUsageAccessPropagationToBase?: boolean; // this flag is for some languages that has no need to generate base model, but generate model with composition -} - -export async function createSdkContext< - TOptions extends Record = SdkEmitterOptions, - TServiceOperation extends SdkServiceOperation = SdkHttpOperation, ->( - context: EmitContext, - emitterName?: string, - options?: CreateSdkContextOptions, -): Promise> { - const diagnostics = createDiagnosticCollector(); - const protocolOptions = true; // context.program.getLibraryOptions("generate-protocol-methods"); - const convenienceOptions = true; // context.program.getLibraryOptions("generate-convenience-methods"); - const generateProtocolMethods = context.options["generate-protocol-methods"] ?? protocolOptions; - const generateConvenienceMethods = - context.options["generate-convenience-methods"] ?? convenienceOptions; - const tcgcContext = createTCGCContext( - context.program, - (emitterName ?? context.program.emitters[0]?.metadata?.name)!, - ); - const sdkContext: SdkContext = { - ...tcgcContext, - emitContext: context, - sdkPackage: undefined!, - generateProtocolMethods: generateProtocolMethods, - generateConvenienceMethods: generateConvenienceMethods, - packageName: context.options["package-name"], - flattenUnionAsEnum: context.options["flatten-union-as-enum"] ?? true, - apiVersion: options?.versioning?.strategy === "ignore" ? "all" : context.options["api-version"], - examplesDir: context.options["examples-dir"] ?? context.options["examples-directory"], - decoratorsAllowList: [...defaultDecoratorsAllowList, ...(options?.additionalDecorators ?? [])], - previewStringRegex: options?.versioning?.previewStringRegex || tcgcContext.previewStringRegex, - disableUsageAccessPropagationToBase: options?.disableUsageAccessPropagationToBase ?? false, - }; - sdkContext.sdkPackage = diagnostics.pipe(getSdkPackage(sdkContext)); - for (const client of sdkContext.sdkPackage.clients) { - diagnostics.pipe(await handleClientExamples(sdkContext, client)); - } - sdkContext.diagnostics = sdkContext.diagnostics.concat(diagnostics.diagnostics); - return sdkContext; -} - const protocolAPIKey = createStateSymbol("protocolAPI"); export const $protocolAPI: ProtocolAPIDecorator = ( diff --git a/packages/typespec-client-generator-core/src/index.ts b/packages/typespec-client-generator-core/src/index.ts index e1e4543438..439794fc95 100644 --- a/packages/typespec-client-generator-core/src/index.ts +++ b/packages/typespec-client-generator-core/src/index.ts @@ -1,3 +1,4 @@ +export * from "./context.js"; export * from "./decorators.js"; export * from "./interfaces.js"; export * from "./lib.js"; diff --git a/packages/typespec-client-generator-core/src/interfaces.ts b/packages/typespec-client-generator-core/src/interfaces.ts index c53f636a39..bb21fc63af 100644 --- a/packages/typespec-client-generator-core/src/interfaces.ts +++ b/packages/typespec-client-generator-core/src/interfaces.ts @@ -76,6 +76,7 @@ export interface SdkEmitterOptions { */ "examples-directory"?: string; "examples-dir"?: string; + "emitter-name"?: string; } export interface SdkClient { diff --git a/packages/typespec-client-generator-core/src/lib.ts b/packages/typespec-client-generator-core/src/lib.ts index 1293df87ec..fa8e0d5000 100644 --- a/packages/typespec-client-generator-core/src/lib.ts +++ b/packages/typespec-client-generator-core/src/lib.ts @@ -1,4 +1,20 @@ -import { createTypeSpecLibrary, paramMessage } from "@typespec/compiler"; +import { createTypeSpecLibrary, JSONSchemaType, paramMessage } from "@typespec/compiler"; +import { SdkEmitterOptions } from "./interfaces.js"; + +const EmitterOptionsSchema: JSONSchemaType = { + type: "object", + additionalProperties: true, + properties: { + "generate-protocol-methods": { type: "boolean", nullable: true }, + "generate-convenience-methods": { type: "boolean", nullable: true }, + "package-name": { type: "string", nullable: true }, + "flatten-union-as-enum": { type: "boolean", nullable: true }, + "api-version": { type: "string", nullable: true }, + "examples-directory": { type: "string", nullable: true }, + "examples-dir": { type: "string", nullable: true }, + "emitter-name": { type: "string", nullable: true }, + }, +}; export const $lib = createTypeSpecLibrary({ name: "@azure-tools/typespec-client-generator-core", @@ -229,6 +245,9 @@ export const $lib = createTypeSpecLibrary({ }, }, }, + emitter: { + options: EmitterOptionsSchema as JSONSchemaType, + }, }); const { reportDiagnostic, createDiagnostic, createStateSymbol } = $lib; diff --git a/packages/typespec-client-generator-core/src/package.ts b/packages/typespec-client-generator-core/src/package.ts index f314793b09..ac72bf2001 100644 --- a/packages/typespec-client-generator-core/src/package.ts +++ b/packages/typespec-client-generator-core/src/package.ts @@ -7,7 +7,6 @@ import { getPagingOperation, getService, getSummary, - ignoreDiagnostics, isList, Model, ModelProperty, @@ -29,7 +28,7 @@ import { shouldGenerateConvenient, shouldGenerateProtocol, } from "./decorators.js"; -import { getCorrespondingMethodParams, getSdkHttpOperation, getSdkHttpParameter } from "./http.js"; +import { getSdkHttpOperation, getSdkHttpParameter } from "./http.js"; import { SdkClient, SdkClientType, @@ -44,7 +43,6 @@ import { SdkMethod, SdkMethodParameter, SdkMethodResponse, - SdkModelPropertyType, SdkModelType, SdkNamespace, SdkNullableType, @@ -55,7 +53,6 @@ import { SdkPathParameter, SdkServiceMethod, SdkServiceOperation, - SdkServiceParameter, SdkType, SdkUnionType, TCGCContext, @@ -487,16 +484,6 @@ function getSdkBasicServiceMethod operation: serviceOperation, response, apiVersions, - getParameterMapping: function getParameterMapping( - serviceParam: SdkServiceParameter, - ): SdkModelPropertyType[] { - return ignoreDiagnostics( - getCorrespondingMethodParams(context, operation, methodParameters, serviceParam), - ); - }, - getResponseMapping: function getResponseMapping(): string | undefined { - return undefined; // currently we only return a value for paging or lro - }, crossLanguageDefintionId: getCrossLanguageDefinitionId(context, operation), decorators: diagnostics.pipe(getTypeDecorators(context, operation)), generateConvenient: shouldGenerateConvenient(context, operation), diff --git a/packages/typespec-client-generator-core/src/public-utils.ts b/packages/typespec-client-generator-core/src/public-utils.ts index 3d100ac2c8..fd67a920fe 100644 --- a/packages/typespec-client-generator-core/src/public-utils.ts +++ b/packages/typespec-client-generator-core/src/public-utils.ts @@ -43,7 +43,6 @@ import { getHttpOperationResponseHeaders, isAzureCoreTspModel, isHttpBodySpread, - parseEmitterName, removeVersionsLargerThanExplicitlySpecified, } from "./internal-utils.js"; import { createDiagnostic } from "./lib.js"; @@ -124,16 +123,6 @@ export function getEffectivePayloadType(context: TCGCContext, type: Model): Mode return type; } -/** - * - * @deprecated This function is deprecated. Please pass in your emitter name as a parameter name to createSdkContext - */ -export function getEmitterTargetName(context: TCGCContext): string { - return ignoreDiagnostics( - parseEmitterName(context.program, context.program.emitters[0]?.metadata?.name), - ); -} - /** * Get the library and wire name of a model property. Takes `@clientName` and `@encodedName` into account * @param context diff --git a/packages/typespec-client-generator-core/src/validate.ts b/packages/typespec-client-generator-core/src/validate.ts index d0deea2358..3b1bb4f61a 100644 --- a/packages/typespec-client-generator-core/src/validate.ts +++ b/packages/typespec-client-generator-core/src/validate.ts @@ -16,7 +16,8 @@ import { UnionVariant, } from "@typespec/compiler"; import { DuplicateTracker } from "@typespec/compiler/utils"; -import { createTCGCContext, getClientNameOverride } from "./decorators.js"; +import { createTCGCContext } from "./context.js"; +import { getClientNameOverride } from "./decorators.js"; import { TCGCContext } from "./interfaces.js"; import { AllScopes, clientNameKey } from "./internal-utils.js"; import { reportDiagnostic } from "./lib.js"; diff --git a/packages/typespec-client-generator-core/test/context/create-context.test.ts b/packages/typespec-client-generator-core/test/context/create-context.test.ts new file mode 100644 index 0000000000..4af8c8e853 --- /dev/null +++ b/packages/typespec-client-generator-core/test/context/create-context.test.ts @@ -0,0 +1,321 @@ +import { AzureCoreTestLibrary } from "@azure-tools/typespec-azure-core/testing"; +import { AzureResourceManagerTestLibrary } from "@azure-tools/typespec-azure-resource-manager/testing"; +import { resolvePath } from "@typespec/compiler"; +import { findTestPackageRoot, resolveVirtualPath } from "@typespec/compiler/testing"; +import { OpenAPITestLibrary } from "@typespec/openapi/testing"; +import { ok, strictEqual } from "assert"; +import { readFile } from "fs/promises"; +import { beforeEach, describe, it } from "vitest"; +import { createSdkContext } from "../../src/context.js"; +import { listClients } from "../../src/decorators.js"; +import { SdkTestLibrary } from "../../src/testing/index.js"; +import { createSdkTestRunner, SdkTestRunner } from "../test-host.js"; + +describe("createSdkContext", () => { + let runner: SdkTestRunner; + + beforeEach(async () => { + runner = await createSdkTestRunner({ emitterName: "@azure-tools/typespec-python" }); + }); + + it("multiple call with versioning", async () => { + const tsp = ` + @service({ + title: "Contoso Widget Manager", + }) + @versioned(Contoso.WidgetManager.Versions) + namespace Contoso.WidgetManager; + + enum Versions { + v1, + } + + @client({name: "TestClient"}) + @test + interface Test {} + `; + + const runnerWithVersion = await createSdkTestRunner({ + emitterName: "@azure-tools/typespec-python", + }); + + await runnerWithVersion.compile(tsp); + let clients = listClients(runnerWithVersion.context); + strictEqual(clients.length, 1); + ok(clients[0].type); + + const newSdkContext = await createSdkContext(runnerWithVersion.context.emitContext); + clients = listClients(newSdkContext); + strictEqual(clients.length, 1); + ok(clients[0].type); + }); + + it("export TCGC output from emitter", async () => { + await runner.compile( + ` + @service({ + title: "Contoso Widget Manager", + }) + namespace Contoso.WidgetManager; + + @usage(Usage.input) + model Test{ + } + `, + { + noEmit: false, + emit: [SdkTestLibrary.name], + options: { + [SdkTestLibrary.name]: { "emitter-output-dir": resolveVirtualPath("tsp-output") }, + }, + }, + ); + + const output = runner.fs.get(resolveVirtualPath("tsp-output", "tcgc-output.yaml")); + const expected = ( + await readFile( + resolvePath( + await findTestPackageRoot(import.meta.url), + "test", + "context", + "output", + "tcgc-output.yaml", + ), + ) + ).toString(); + strictEqual(output, expected); + }); + + it("export complex TCGC output from emitter", async () => { + runner = await createSdkTestRunner({ + librariesToAdd: [AzureResourceManagerTestLibrary, AzureCoreTestLibrary, OpenAPITestLibrary], + autoUsings: ["Azure.ResourceManager", "Azure.Core"], + emitterName: "@azure-tools/typespec-python", + }); + + await runner.compile( + ` + @armProviderNamespace + @service({ + title: "ContosoProviderHubClient", + }) + @versioned(Versions) + namespace Microsoft.ContosoProviderHub; + + /** Contoso API versions */ + enum Versions { + /** 2021-10-01-preview version */ + @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5) + "2021-10-01-preview", + } + + /** A ContosoProviderHub resource */ + model Employee is TrackedResource { + ...ResourceNameParameter; + } + + /** Employee properties */ + model EmployeeProperties { + /** Age of employee */ + age?: int32; + + /** City of employee */ + city?: string; + + /** Profile of employee */ + @encode("base64url") + profile?: bytes; + + /** The status of the last operation. */ + @visibility("read") + provisioningState?: ProvisioningState; + } + + /** The provisioning state of a resource. */ + @lroStatus + union ProvisioningState { + string, + + /** The resource create request has been accepted */ + Accepted: "Accepted", + + /** The resource is being provisioned */ + Provisioning: "Provisioning", + + /** The resource is updating */ + Updating: "Updating", + + /** Resource has been created. */ + Succeeded: "Succeeded", + + /** Resource creation failed. */ + Failed: "Failed", + + /** Resource creation was canceled. */ + Canceled: "Canceled", + + /** The resource is being deleted */ + Deleting: "Deleting", + } + + /** Employee move request */ + model MoveRequest { + /** The moving from location */ + from: string; + + /** The moving to location */ + to: string; + } + + /** Employee move response */ + model MoveResponse { + /** The status of the move */ + movingStatus: string; + } + + interface Operations extends Azure.ResourceManager.Operations {} + + @armResourceOperations + interface Employees { + get is ArmResourceRead; + createOrUpdate is ArmResourceCreateOrReplaceAsync; + update is ArmResourcePatchSync; + delete is ArmResourceDeleteWithoutOkAsync; + listByResourceGroup is ArmResourceListByParent; + listBySubscription is ArmListBySubscription; + + /** A sample resource action that move employee to different location */ + move is ArmResourceActionSync; + + /** A sample HEAD operation to check resource existence */ + checkExistence is ArmResourceCheckExistence; + } + `, + { + noEmit: false, + emit: [SdkTestLibrary.name], + options: { + [SdkTestLibrary.name]: { "emitter-output-dir": resolveVirtualPath("tsp-output") }, + }, + }, + ); + + const output = runner.fs.get(resolveVirtualPath("tsp-output", "tcgc-output.yaml")); + const expected = ( + await readFile( + resolvePath( + await findTestPackageRoot(import.meta.url), + "test", + "context", + "output", + "tcgc-output-complex.yaml", + ), + ) + ).toString(); + strictEqual(output, expected); + }); + + it("export TCGC output with emitter name from emitter", async () => { + await runner.compile( + ` + @service({ + title: "Contoso Widget Manager", + }) + namespace Contoso.WidgetManager; + + @usage(Usage.input, "csharp") + model Test{ + } + `, + { + noEmit: false, + emit: [SdkTestLibrary.name], + options: { + [SdkTestLibrary.name]: { + "emitter-output-dir": resolveVirtualPath("tsp-output"), + "emitter-name": "@azure-tools/typespec-csharp", + }, + }, + }, + ); + + const output = runner.fs.get(resolveVirtualPath("tsp-output", "tcgc-output.yaml")); + const expected = ( + await readFile( + resolvePath( + await findTestPackageRoot(import.meta.url), + "test", + "context", + "output", + "tcgc-output.yaml", + ), + ) + ).toString(); + strictEqual(output, expected); + }); + + it("export TCGC output from context", async () => { + runner = await createSdkTestRunner( + { emitterName: "@azure-tools/typespec-python" }, + { exportTCGCoutput: true }, + ); + + await runner.compile(` + @service({ + title: "Contoso Widget Manager", + }) + namespace Contoso.WidgetManager; + + @usage(Usage.input) + model Test{ + } + `); + + const output = runner.fs.get(resolveVirtualPath("tsp-output", "tcgc-output.yaml")); + const expected = ( + await readFile( + resolvePath( + await findTestPackageRoot(import.meta.url), + "test", + "context", + "output", + "tcgc-output.yaml", + ), + ) + ).toString(); + strictEqual(output, expected); + }); + + it("export TCGC output with emitter name from context", async () => { + runner = await createSdkTestRunner( + { emitterName: "@azure-tools/typespec-python" }, + { exportTCGCoutput: true }, + ); + + await runner.compile(` + @service({ + title: "Contoso Widget Manager", + }) + namespace Contoso.WidgetManager; + + @usage(Usage.input, "python") + model Test{ + } + `); + + const output = runner.fs.get(resolveVirtualPath("tsp-output", "tcgc-output.yaml")); + const expected = ( + await readFile( + resolvePath( + await findTestPackageRoot(import.meta.url), + "test", + "context", + "output", + "tcgc-output.yaml", + ), + ) + ).toString(); + strictEqual(output, expected); + }); +}); diff --git a/packages/typespec-client-generator-core/test/context/output/tcgc-output-complex.yaml b/packages/typespec-client-generator-core/test/context/output/tcgc-output-complex.yaml new file mode 100644 index 0000000000..15a869890c --- /dev/null +++ b/packages/typespec-client-generator-core/test/context/output/tcgc-output-complex.yaml @@ -0,0 +1,4161 @@ +name: Microsoft.ContosoProviderHub +rootNamespace: Microsoft.ContosoProviderHub +clients: + - &a13 + kind: client + name: ContosoProviderHubClient + methods: + - kind: clientaccessor + parameters: [] + name: getOperations + access: internal + response: &a95 + kind: client + name: Operations + methods: + - kind: paging + name: list + access: public + parameters: + - &a4 + type: &a1 + kind: constant + value: application/json + valueType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: listContentType + isGeneratedName: true + decorators: [] + name: accept + isGeneratedName: true + apiVersions: &a2 + - 2021-10-01-preview + isApiVersionParam: false + onClient: false + optional: false + crossLanguageDefinitionId: Azure.ResourceManager.Operations.list.accept + decorators: &a3 [] + kind: method + doc: List the operations for the provider + operation: + kind: http + path: /providers/Microsoft.ContosoProviderHub/operations + uriTemplate: /providers/Microsoft.ContosoProviderHub/operations{?api-version} + verb: get + parameters: + - doc: The API version to use for this operation. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: apiVersion + isGeneratedName: false + optional: false + isApiVersionParam: true + clientDefaultValue: 2021-10-01-preview + onClient: true + crossLanguageDefinitionId: Azure.ResourceManager..anonymous.apiVersion + decorators: [] + correspondingMethodParams: + - &a12 + doc: The API version to use for this operation. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: apiVersion + isGeneratedName: false + optional: false + isApiVersionParam: true + clientDefaultValue: 2021-10-01-preview + onClient: true + crossLanguageDefinitionId: Azure.ResourceManager..anonymous.apiVersion + decorators: [] + correspondingMethodParams: [] + kind: method + serializedName: api-version + kind: query + serializedName: api-version + explode: false + - type: *a1 + name: accept + isGeneratedName: true + apiVersions: *a2 + isApiVersionParam: false + onClient: false + optional: false + crossLanguageDefinitionId: Azure.ResourceManager.Operations.list.accept + decorators: *a3 + kind: header + serializedName: Accept + correspondingMethodParams: + - *a4 + responses: + - type: &a91 + kind: model + decorators: [] + name: OperationListResult + isGeneratedName: false + clientNamespace: Azure.ResourceManager.CommonTypes + doc: A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + properties: + - doc: The Operation items on this page + apiVersions: + - 1.0-preview.1 + - 1.0-preview.2 + type: + kind: array + decorators: [] + name: ArrayOperation + valueType: &a10 + kind: model + decorators: [] + name: Operation + isGeneratedName: false + clientNamespace: Azure.ResourceManager.CommonTypes + doc: Details of a REST API operation, returned from the Resource Provider Operations API + properties: + - doc: 'The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action"' + apiVersions: + - v3 + - v4 + - v5 + - v6 + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: name + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.Operation.name + decorators: [] + kind: property + visibility: + - 1 + discriminator: false + serializedName: name + isMultipartFileInput: false + flatten: false + - doc: Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure Resource Manager/control-plane operations. + apiVersions: + - v3 + - v4 + - v5 + - v6 + type: + kind: boolean + decorators: [] + name: boolean + doc: Boolean with `true` and `false` values. + crossLanguageDefinitionId: TypeSpec.boolean + name: isDataAction + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.Operation.isDataAction + decorators: [] + kind: property + visibility: + - 1 + discriminator: false + serializedName: isDataAction + isMultipartFileInput: false + flatten: false + - doc: Localized display information for this particular operation. + apiVersions: + - v3 + - v4 + - v5 + - v6 + type: &a92 + kind: model + decorators: [] + name: OperationDisplay + isGeneratedName: false + clientNamespace: Azure.ResourceManager.CommonTypes + doc: Localized display information for and operation. + properties: + - doc: The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". + apiVersions: + - v3 + - v4 + - v5 + - v6 + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: provider + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.OperationDisplay.provider + decorators: [] + kind: property + visibility: + - 1 + discriminator: false + serializedName: provider + isMultipartFileInput: false + flatten: false + - doc: The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". + apiVersions: + - v3 + - v4 + - v5 + - v6 + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: resource + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.OperationDisplay.resource + decorators: [] + kind: property + visibility: + - 1 + discriminator: false + serializedName: resource + isMultipartFileInput: false + flatten: false + - doc: The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + apiVersions: + - v3 + - v4 + - v5 + - v6 + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: operation + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.OperationDisplay.operation + decorators: [] + kind: property + visibility: + - 1 + discriminator: false + serializedName: operation + isMultipartFileInput: false + flatten: false + - doc: The short, localized friendly description of the operation; suitable for tool tips and detailed views. + apiVersions: + - v3 + - v4 + - v5 + - v6 + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: description + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.OperationDisplay.description + decorators: [] + kind: property + visibility: + - 1 + discriminator: false + serializedName: description + isMultipartFileInput: false + flatten: false + access: public + usage: 260 + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.OperationDisplay + apiVersions: + - v3 + - v4 + - v5 + - v6 + name: display + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.Operation.display + decorators: [] + kind: property + visibility: + - 1 + discriminator: false + serializedName: display + isMultipartFileInput: false + flatten: false + - doc: The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" + apiVersions: + - v3 + - v4 + - v5 + - v6 + type: &a6 + kind: enum + decorators: [] + name: Origin + isGeneratedName: false + clientNamespace: Azure.ResourceManager.CommonTypes + doc: The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" + valueType: &a5 + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + values: + - kind: enumvalue + decorators: [] + name: user + doc: Indicates the operation is initiated by a user. + value: user + valueType: *a5 + enumType: *a6 + - kind: enumvalue + decorators: [] + name: system + doc: Indicates the operation is initiated by a system. + value: system + valueType: *a5 + enumType: *a6 + - kind: enumvalue + decorators: [] + name: user,system + doc: Indicates the operation is initiated by a user or system. + value: user,system + valueType: *a5 + enumType: *a6 + isFixed: false + isFlags: false + usage: 260 + access: public + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.Origin + apiVersions: + - v3 + - v4 + - v5 + - v6 + isUnionAsEnum: true + name: origin + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.Operation.origin + decorators: [] + kind: property + visibility: + - 1 + discriminator: false + serializedName: origin + isMultipartFileInput: false + flatten: false + - doc: Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + apiVersions: + - v3 + - v4 + - v5 + - v6 + type: &a8 + kind: enum + decorators: [] + name: ActionType + isGeneratedName: false + clientNamespace: Azure.ResourceManager.CommonTypes + doc: Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + valueType: &a7 + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + values: + - kind: enumvalue + decorators: [] + name: Internal + doc: Actions are for internal-only APIs. + value: Internal + valueType: *a7 + enumType: *a8 + isFixed: false + isFlags: false + usage: 260 + access: public + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.ActionType + apiVersions: + - v3 + - v4 + - v5 + - v6 + isUnionAsEnum: true + name: actionType + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.Operation.actionType + decorators: [] + kind: property + discriminator: false + serializedName: actionType + isMultipartFileInput: false + flatten: false + access: public + usage: 260 + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.Operation + apiVersions: + - v3 + - v4 + - v5 + - v6 + crossLanguageDefinitionId: TypeSpec.Array + name: value + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.OperationListResult.value + decorators: [] + kind: property + discriminator: false + serializedName: value + isMultipartFileInput: false + flatten: false + - doc: The link to the next page of items + apiVersions: + - 1.0-preview.1 + - 1.0-preview.2 + type: + kind: url + decorators: [] + name: ResourceLocation + doc: The location of an instance of Operation + baseType: + kind: url + decorators: [] + name: url + doc: Represent a URL string as described by https://url.spec.whatwg.org/ + crossLanguageDefinitionId: TypeSpec.url + crossLanguageDefinitionId: TypeSpec.Rest.ResourceLocation + name: nextLink + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.OperationListResult.nextLink + decorators: [] + kind: property + discriminator: false + serializedName: nextLink + isMultipartFileInput: false + flatten: false + access: public + usage: 260 + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.OperationListResult + apiVersions: + - v3 + - v4 + - v5 + - v6 + headers: [] + contentTypes: + - application/json + defaultContentType: application/json + apiVersions: *a2 + description: Azure operation completed successfully. + kind: http + statusCodes: 200 + exceptions: + - type: &a24 + kind: model + decorators: [] + name: ErrorResponse + isGeneratedName: false + clientNamespace: Azure.ResourceManager.CommonTypes + doc: Common error response for all Azure Resource Manager APIs to return error details for failed operations. + properties: + - doc: The error object. + apiVersions: + - v3 + - v4 + - v5 + - v6 + type: &a9 + kind: model + decorators: [] + name: ErrorDetail + isGeneratedName: false + clientNamespace: Azure.ResourceManager.CommonTypes + doc: The error detail. + properties: + - doc: The error code. + apiVersions: + - v3 + - v4 + - v5 + - v6 + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: code + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.ErrorDetail.code + decorators: [] + kind: property + visibility: + - 1 + discriminator: false + serializedName: code + isMultipartFileInput: false + flatten: false + - doc: The error message. + apiVersions: + - v3 + - v4 + - v5 + - v6 + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: message + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.ErrorDetail.message + decorators: [] + kind: property + visibility: + - 1 + discriminator: false + serializedName: message + isMultipartFileInput: false + flatten: false + - doc: The error target. + apiVersions: + - v3 + - v4 + - v5 + - v6 + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: target + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.ErrorDetail.target + decorators: [] + kind: property + visibility: + - 1 + discriminator: false + serializedName: target + isMultipartFileInput: false + flatten: false + - doc: The error details. + apiVersions: + - v3 + - v4 + - v5 + - v6 + type: + kind: array + decorators: [] + name: ArrayErrorDetail + valueType: *a9 + crossLanguageDefinitionId: TypeSpec.Array + name: details + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.ErrorDetail.details + decorators: [] + kind: property + visibility: + - 1 + discriminator: false + serializedName: details + isMultipartFileInput: false + flatten: false + - doc: The error additional info. + apiVersions: + - v3 + - v4 + - v5 + - v6 + type: + kind: array + decorators: [] + name: ArrayErrorAdditionalInfo + valueType: &a89 + kind: model + decorators: [] + name: ErrorAdditionalInfo + isGeneratedName: false + clientNamespace: Azure.ResourceManager.CommonTypes + doc: The resource management error additional info. + properties: + - doc: The additional info type. + apiVersions: + - v3 + - v4 + - v5 + - v6 + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: type + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo.type + decorators: [] + kind: property + visibility: + - 1 + discriminator: false + serializedName: type + isMultipartFileInput: false + flatten: false + - doc: The additional info. + apiVersions: + - v3 + - v4 + - v5 + - v6 + type: &a90 + kind: model + decorators: [] + name: ErrorAdditionalInfoInfo + isGeneratedName: true + clientNamespace: Azure.ResourceManager.CommonTypes + properties: [] + access: public + usage: 5376 + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo.info.anonymous + apiVersions: + - v3 + - v4 + - v5 + - v6 + name: info + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo.info + decorators: [] + kind: property + visibility: + - 1 + discriminator: false + serializedName: info + isMultipartFileInput: false + flatten: false + access: public + usage: 5376 + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo + apiVersions: + - v3 + - v4 + - v5 + - v6 + crossLanguageDefinitionId: TypeSpec.Array + name: additionalInfo + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.ErrorDetail.additionalInfo + decorators: [] + kind: property + visibility: + - 1 + discriminator: false + serializedName: additionalInfo + isMultipartFileInput: false + flatten: false + access: public + usage: 5376 + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.ErrorDetail + apiVersions: + - v3 + - v4 + - v5 + - v6 + name: error + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.ErrorResponse.error + decorators: [] + kind: property + discriminator: false + serializedName: error + isMultipartFileInput: false + flatten: false + access: public + usage: 1408 + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.ErrorResponse + apiVersions: + - v3 + - v4 + - v5 + - v6 + headers: [] + contentTypes: + - application/json + defaultContentType: application/json + apiVersions: + - 2021-10-01-preview + kind: http + statusCodes: "*" + response: + kind: method + type: + kind: array + decorators: [] + name: ArrayOperation + valueType: *a10 + crossLanguageDefinitionId: TypeSpec.Array + resultPath: value + apiVersions: + - 2021-10-01-preview + crossLanguageDefintionId: Azure.ResourceManager.Operations.list + decorators: [] + generateConvenient: true + generateProtocol: true + isOverride: false + nextLinkPath: nextLink + apiVersions: &a11 + - 2021-10-01-preview + nameSpace: Microsoft.ContosoProviderHub + clientNamespace: Microsoft.ContosoProviderHub + initialization: + doc: Initialization class for the client + kind: model + properties: + - kind: endpoint + type: + kind: endpoint + serverUrl: "{endpoint}" + templateArguments: + - name: endpoint + isGeneratedName: true + doc: Service host + kind: path + onClient: true + urlEncode: false + explode: false + style: simple + allowReserved: false + optional: false + serializedName: endpoint + correspondingMethodParams: [] + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + isApiVersionParam: false + apiVersions: *a11 + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.endpoint + decorators: [] + clientDefaultValue: https://management.azure.com + decorators: [] + name: endpoint + isGeneratedName: true + doc: Service host + onClient: true + urlEncode: false + apiVersions: *a11 + optional: false + isApiVersionParam: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.endpoint + decorators: [] + - type: + kind: credential + decorators: [] + kind: credential + name: credential + isGeneratedName: true + doc: Credential used to authenticate requests to the service. + apiVersions: + - 2021-10-01-preview + onClient: true + optional: false + isApiVersionParam: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.credential + decorators: [] + - *a12 + name: OperationsOptions + isGeneratedName: true + access: internal + usage: 2 + crossLanguageDefinitionId: Microsoft.OperationsOptions + clientNamespace: Microsoft.ContosoProviderHub + apiVersions: *a11 + decorators: [] + decorators: [] + parent: *a13 + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.Operations + apiVersions: + - 2021-10-01-preview + crossLanguageDefintionId: Microsoft.ContosoProviderHub.Operations + decorators: [] + - kind: clientaccessor + parameters: [] + name: getEmployees + access: internal + response: &a96 + kind: client + name: Employees + methods: + - kind: basic + name: get + access: public + parameters: + - &a14 + doc: The name of the resource group. The name is case insensitive. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: resourceGroupName + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.resourceGroupName + decorators: [] + kind: method + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: resourceGroupName + correspondingMethodParams: [] + - &a15 + doc: The name of the Employee + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: employeeName + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.employeeName + decorators: [] + kind: method + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: employeeName + correspondingMethodParams: [] + - &a19 + type: &a16 + kind: constant + value: application/json + valueType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: getContentType + isGeneratedName: true + decorators: [] + name: accept + isGeneratedName: true + apiVersions: &a17 + - 2021-10-01-preview + isApiVersionParam: false + onClient: false + optional: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.Employees.get.accept + decorators: &a18 [] + kind: method + doc: Get a Employee + operation: + kind: http + path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContosoProviderHub/employees/{employeeName} + uriTemplate: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContosoProviderHub/employees/{employeeName}{?api-version} + verb: get + parameters: + - doc: The API version to use for this operation. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: apiVersion + isGeneratedName: false + optional: false + isApiVersionParam: true + clientDefaultValue: 2021-10-01-preview + onClient: true + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.apiVersion + decorators: [] + correspondingMethodParams: + - &a26 + doc: The API version to use for this operation. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: apiVersion + isGeneratedName: false + optional: false + isApiVersionParam: true + clientDefaultValue: 2021-10-01-preview + onClient: true + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.apiVersion + decorators: [] + correspondingMethodParams: [] + kind: method + serializedName: api-version + kind: query + serializedName: api-version + explode: false + - doc: The ID of the target subscription. The value must be an UUID. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: uuid + doc: Universally Unique Identifier + baseType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + crossLanguageDefinitionId: Azure.Core.uuid + name: subscriptionId + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: true + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.subscriptionId + decorators: [] + kind: path + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: subscriptionId + correspondingMethodParams: + - &a27 + doc: The ID of the target subscription. The value must be an UUID. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: uuid + doc: Universally Unique Identifier + baseType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + crossLanguageDefinitionId: Azure.Core.uuid + name: subscriptionId + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: true + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.subscriptionId + decorators: [] + kind: method + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: subscriptionId + correspondingMethodParams: [] + - doc: The name of the resource group. The name is case insensitive. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: resourceGroupName + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.resourceGroupName + decorators: [] + kind: path + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: resourceGroupName + correspondingMethodParams: + - *a14 + - doc: The name of the Employee + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: employeeName + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.employeeName + decorators: [] + kind: path + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: employeeName + correspondingMethodParams: + - *a15 + - type: *a16 + name: accept + isGeneratedName: true + apiVersions: *a17 + isApiVersionParam: false + onClient: false + optional: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.Employees.get.accept + decorators: *a18 + kind: header + serializedName: Accept + correspondingMethodParams: + - *a19 + responses: + - type: &a25 + kind: model + decorators: [] + name: Employee + isGeneratedName: false + clientNamespace: Microsoft.ContosoProviderHub + doc: A ContosoProviderHub resource + properties: + - doc: The resource-specific properties for this resource. + apiVersions: + - 1.0-preview.1 + type: &a85 + kind: model + decorators: [] + name: EmployeeProperties + isGeneratedName: false + clientNamespace: Microsoft.ContosoProviderHub + doc: Employee properties + properties: + - doc: Age of employee + apiVersions: + - 2021-10-01-preview + type: + kind: int32 + decorators: [] + name: int32 + doc: A 32-bit integer. (`-2,147,483,648` to `2,147,483,647`) + crossLanguageDefinitionId: TypeSpec.int32 + name: age + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.EmployeeProperties.age + decorators: [] + kind: property + discriminator: false + serializedName: age + isMultipartFileInput: false + flatten: false + - doc: City of employee + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: city + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.EmployeeProperties.city + decorators: [] + kind: property + discriminator: false + serializedName: city + isMultipartFileInput: false + flatten: false + - doc: Profile of employee + apiVersions: + - 2021-10-01-preview + type: + kind: bytes + decorators: [] + name: bytes + encode: base64url + doc: Represent a byte array + crossLanguageDefinitionId: TypeSpec.bytes + name: profile + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.EmployeeProperties.profile + decorators: [] + kind: property + discriminator: false + serializedName: profile + isMultipartFileInput: false + flatten: false + - doc: The status of the last operation. + apiVersions: + - 2021-10-01-preview + type: &a21 + kind: enum + decorators: [] + name: ProvisioningState + isGeneratedName: false + clientNamespace: Microsoft.ContosoProviderHub + doc: The provisioning state of a resource. + valueType: &a20 + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + values: + - kind: enumvalue + decorators: [] + name: Accepted + doc: The resource create request has been accepted + value: Accepted + valueType: *a20 + enumType: *a21 + - kind: enumvalue + decorators: [] + name: Provisioning + doc: The resource is being provisioned + value: Provisioning + valueType: *a20 + enumType: *a21 + - kind: enumvalue + decorators: [] + name: Updating + doc: The resource is updating + value: Updating + valueType: *a20 + enumType: *a21 + - kind: enumvalue + decorators: [] + name: Succeeded + doc: Resource has been created. + value: Succeeded + valueType: *a20 + enumType: *a21 + - kind: enumvalue + decorators: [] + name: Failed + doc: Resource creation failed. + value: Failed + valueType: *a20 + enumType: *a21 + - kind: enumvalue + decorators: [] + name: Canceled + doc: Resource creation was canceled. + value: Canceled + valueType: *a20 + enumType: *a21 + - kind: enumvalue + decorators: [] + name: Deleting + doc: The resource is being deleted + value: Deleting + valueType: *a20 + enumType: *a21 + isFixed: false + isFlags: false + usage: 10500 + access: public + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.ProvisioningState + apiVersions: + - 2021-10-01-preview + isUnionAsEnum: true + name: provisioningState + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.EmployeeProperties.provisioningState + decorators: [] + kind: property + visibility: + - 1 + discriminator: false + serializedName: provisioningState + isMultipartFileInput: false + flatten: false + access: public + usage: 10502 + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.EmployeeProperties + apiVersions: + - 2021-10-01-preview + name: properties + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.Employee.properties + decorators: [] + kind: property + discriminator: false + serializedName: properties + isMultipartFileInput: false + flatten: false + - doc: The name of the Employee + apiVersions: + - 1.0-preview.1 + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: name + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.Employee.name + decorators: [] + kind: path + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: name + correspondingMethodParams: [] + access: public + usage: 10502 + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.Employee + apiVersions: + - 2021-10-01-preview + baseModel: &a86 + kind: model + decorators: [] + name: TrackedResource + isGeneratedName: false + clientNamespace: Azure.ResourceManager.CommonTypes + doc: The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location' + properties: + - doc: Resource tags. + apiVersions: + - v3 + - v4 + - v5 + - v6 + type: + kind: dict + decorators: [] + keyType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + valueType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: tags + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.TrackedResource.tags + decorators: [] + kind: property + discriminator: false + serializedName: tags + isMultipartFileInput: false + flatten: false + - doc: The geo-location where the resource lives + apiVersions: + - v3 + - v4 + - v5 + - v6 + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: location + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.TrackedResource.location + decorators: [] + kind: property + visibility: + - 1 + - 2 + discriminator: false + serializedName: location + isMultipartFileInput: false + flatten: false + access: public + usage: 10502 + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.TrackedResource + apiVersions: + - v3 + - v4 + - v5 + - v6 + baseModel: &a87 + kind: model + decorators: [] + name: Resource + isGeneratedName: false + clientNamespace: Azure.ResourceManager.CommonTypes + doc: Common fields that are returned in the response for all Azure Resource Manager resources + properties: + - doc: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + apiVersions: + - v3 + - v4 + - v5 + - v6 + type: + kind: string + decorators: [] + name: armResourceIdentifier + doc: A type definition that refers the id to an Azure Resource Manager resource. + baseType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + crossLanguageDefinitionId: Azure.Core.armResourceIdentifier + name: id + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.Resource.id + decorators: [] + kind: property + visibility: + - 1 + discriminator: false + serializedName: id + isMultipartFileInput: false + flatten: false + - doc: The name of the resource + apiVersions: + - v3 + - v4 + - v5 + - v6 + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: name + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.Resource.name + decorators: [] + kind: property + visibility: + - 1 + discriminator: false + serializedName: name + isMultipartFileInput: false + flatten: false + - doc: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + apiVersions: + - v3 + - v4 + - v5 + - v6 + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: type + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.Resource.type + decorators: [] + kind: property + visibility: + - 1 + discriminator: false + serializedName: type + isMultipartFileInput: false + flatten: false + - doc: Azure Resource Manager metadata containing createdBy and modifiedBy information. + apiVersions: + - v3 + - v4 + - v5 + - v6 + type: &a88 + kind: model + decorators: [] + name: SystemData + isGeneratedName: false + clientNamespace: Azure.ResourceManager.CommonTypes + doc: Metadata pertaining to creation and last modification of the resource. + properties: + - doc: The identity that created the resource. + apiVersions: + - v3 + - v4 + - v5 + - v6 + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: createdBy + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.SystemData.createdBy + decorators: [] + kind: property + discriminator: false + serializedName: createdBy + isMultipartFileInput: false + flatten: false + - doc: The type of identity that created the resource. + apiVersions: + - v3 + - v4 + - v5 + - v6 + type: &a23 + kind: enum + decorators: [] + name: createdByType + isGeneratedName: false + clientNamespace: Azure.ResourceManager.CommonTypes + doc: The kind of entity that created the resource. + valueType: &a22 + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + values: + - kind: enumvalue + decorators: [] + name: User + doc: The entity was created by a user. + value: User + valueType: *a22 + enumType: *a23 + - kind: enumvalue + decorators: [] + name: Application + doc: The entity was created by an application. + value: Application + valueType: *a22 + enumType: *a23 + - kind: enumvalue + decorators: [] + name: ManagedIdentity + doc: The entity was created by a managed identity. + value: ManagedIdentity + valueType: *a22 + enumType: *a23 + - kind: enumvalue + decorators: [] + name: Key + doc: The entity was created by a key. + value: Key + valueType: *a22 + enumType: *a23 + isFixed: false + isFlags: false + usage: 10500 + access: public + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.createdByType + apiVersions: + - v3 + - v4 + - v5 + - v6 + isUnionAsEnum: true + name: createdByType + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.SystemData.createdByType + decorators: [] + kind: property + discriminator: false + serializedName: createdByType + isMultipartFileInput: false + flatten: false + - doc: The timestamp of resource creation (UTC). + apiVersions: + - v3 + - v4 + - v5 + - v6 + type: + kind: utcDateTime + decorators: [] + name: utcDateTime + encode: rfc3339 + wireType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + doc: An instant in coordinated universal time (UTC)" + crossLanguageDefinitionId: TypeSpec.utcDateTime + name: createdAt + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.SystemData.createdAt + decorators: [] + kind: property + discriminator: false + serializedName: createdAt + isMultipartFileInput: false + flatten: false + - doc: The identity that last modified the resource. + apiVersions: + - v3 + - v4 + - v5 + - v6 + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: lastModifiedBy + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.SystemData.lastModifiedBy + decorators: [] + kind: property + discriminator: false + serializedName: lastModifiedBy + isMultipartFileInput: false + flatten: false + - doc: The type of identity that last modified the resource. + apiVersions: + - v3 + - v4 + - v5 + - v6 + type: *a23 + name: lastModifiedByType + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.SystemData.lastModifiedByType + decorators: [] + kind: property + discriminator: false + serializedName: lastModifiedByType + isMultipartFileInput: false + flatten: false + - doc: The timestamp of resource last modification (UTC) + apiVersions: + - v3 + - v4 + - v5 + - v6 + type: + kind: utcDateTime + decorators: [] + name: utcDateTime + encode: rfc3339 + wireType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + doc: An instant in coordinated universal time (UTC)" + crossLanguageDefinitionId: TypeSpec.utcDateTime + name: lastModifiedAt + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.SystemData.lastModifiedAt + decorators: [] + kind: property + discriminator: false + serializedName: lastModifiedAt + isMultipartFileInput: false + flatten: false + access: public + usage: 10500 + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.SystemData + apiVersions: + - v3 + - v4 + - v5 + - v6 + name: systemData + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.Resource.systemData + decorators: [] + kind: property + visibility: + - 1 + discriminator: false + serializedName: systemData + isMultipartFileInput: false + flatten: false + access: public + usage: 10502 + crossLanguageDefinitionId: Azure.ResourceManager.CommonTypes.Resource + apiVersions: + - v3 + - v4 + - v5 + - v6 + headers: [] + contentTypes: + - application/json + defaultContentType: application/json + apiVersions: *a17 + description: Azure operation completed successfully. + kind: http + statusCodes: 200 + exceptions: + - type: *a24 + headers: [] + contentTypes: + - application/json + defaultContentType: application/json + apiVersions: + - 2021-10-01-preview + kind: http + statusCodes: "*" + response: + kind: method + type: *a25 + apiVersions: + - 2021-10-01-preview + crossLanguageDefintionId: Microsoft.ContosoProviderHub.Employees.get + decorators: [] + generateConvenient: true + generateProtocol: true + isOverride: false + - kind: lro + name: createOrUpdate + access: public + parameters: + - &a28 + doc: The name of the resource group. The name is case insensitive. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: resourceGroupName + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.resourceGroupName + decorators: [] + kind: method + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: resourceGroupName + correspondingMethodParams: [] + - &a29 + doc: The name of the Employee + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: employeeName + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.employeeName + decorators: [] + kind: method + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: employeeName + correspondingMethodParams: [] + - &a33 + doc: Resource create parameters. + apiVersions: + - 2021-10-01-preview + type: *a25 + name: resource + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.resource + decorators: [] + kind: method + discriminator: false + serializedName: resource + isMultipartFileInput: false + flatten: false + - &a30 + type: + kind: constant + value: application/json + valueType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: createOrUpdateContentType + isGeneratedName: true + decorators: [] + name: contentType + isGeneratedName: true + apiVersions: + - 2021-10-01-preview + isApiVersionParam: false + onClient: false + optional: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.Employees.createOrUpdate.contentType + decorators: [] + doc: Body parameter's content type. Known values are application/json + kind: method + - &a31 + type: + kind: constant + value: application/json + valueType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: createOrUpdateContentType + isGeneratedName: true + decorators: [] + name: accept + isGeneratedName: true + apiVersions: + - 2021-10-01-preview + isApiVersionParam: false + onClient: false + optional: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.Employees.createOrUpdate.accept + decorators: [] + kind: method + doc: Create a Employee + operation: + kind: http + path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContosoProviderHub/employees/{employeeName} + uriTemplate: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContosoProviderHub/employees/{employeeName}{?api-version} + verb: put + parameters: + - doc: The API version to use for this operation. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: apiVersion + isGeneratedName: false + optional: false + isApiVersionParam: true + clientDefaultValue: 2021-10-01-preview + onClient: true + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.apiVersion + decorators: [] + correspondingMethodParams: + - *a26 + kind: query + serializedName: api-version + explode: false + - doc: The ID of the target subscription. The value must be an UUID. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: uuid + doc: Universally Unique Identifier + baseType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + crossLanguageDefinitionId: Azure.Core.uuid + name: subscriptionId + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: true + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.subscriptionId + decorators: [] + kind: path + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: subscriptionId + correspondingMethodParams: + - *a27 + - doc: The name of the resource group. The name is case insensitive. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: resourceGroupName + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.resourceGroupName + decorators: [] + kind: path + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: resourceGroupName + correspondingMethodParams: + - *a28 + - doc: The name of the Employee + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: employeeName + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.employeeName + decorators: [] + kind: path + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: employeeName + correspondingMethodParams: + - *a29 + - type: + kind: constant + value: application/json + valueType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: createOrUpdateContentType + isGeneratedName: true + decorators: [] + name: contentType + isGeneratedName: true + apiVersions: &a32 + - 2021-10-01-preview + isApiVersionParam: false + onClient: false + optional: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.Employees.createOrUpdate.contentType + decorators: [] + doc: Body parameter's content type. Known values are application/json + kind: header + serializedName: Content-Type + correspondingMethodParams: + - *a30 + - type: + kind: constant + value: application/json + valueType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: createOrUpdateContentType + isGeneratedName: true + decorators: [] + name: accept + isGeneratedName: true + apiVersions: &a34 + - 2021-10-01-preview + isApiVersionParam: false + onClient: false + optional: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.Employees.createOrUpdate.accept + decorators: [] + kind: header + serializedName: Accept + correspondingMethodParams: + - *a31 + bodyParam: + doc: Resource create parameters. + apiVersions: *a32 + type: *a25 + name: resource + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.resource + decorators: [] + kind: body + serializedName: resource + contentTypes: + - application/json + defaultContentType: application/json + correspondingMethodParams: + - *a33 + responses: + - type: *a25 + headers: [] + contentTypes: + - application/json + defaultContentType: application/json + apiVersions: *a34 + description: Resource 'Employee' update operation succeeded + kind: http + statusCodes: 200 + - type: *a25 + headers: + - doc: A link to the status monitor + serializedName: Azure-AsyncOperation + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + - doc: The Retry-After header can indicate how long the client should wait before polling the operation status. + serializedName: Retry-After + type: + kind: int32 + decorators: [] + name: int32 + doc: A 32-bit integer. (`-2,147,483,648` to `2,147,483,647`) + crossLanguageDefinitionId: TypeSpec.int32 + contentTypes: + - application/json + defaultContentType: application/json + apiVersions: + - 2021-10-01-preview + description: Resource 'Employee' create operation succeeded + kind: http + statusCodes: 201 + exceptions: + - type: *a24 + headers: [] + contentTypes: + - application/json + defaultContentType: application/json + apiVersions: + - 2021-10-01-preview + kind: http + statusCodes: "*" + response: + kind: method + type: *a25 + apiVersions: + - 2021-10-01-preview + crossLanguageDefintionId: Microsoft.ContosoProviderHub.Employees.createOrUpdate + decorators: [] + generateConvenient: true + generateProtocol: true + isOverride: false + lroMetadata: + finalStateVia: azure-async-operation + finalResponse: + envelopeResult: *a25 + result: *a25 + finalStep: + kind: finalOperationLink + pollingStep: + responseBody: &a52 + kind: model + decorators: [] + name: ArmOperationStatusResourceProvisioningState + isGeneratedName: false + clientNamespace: Azure.ResourceManager + doc: Standard Azure Resource Manager operation status response + properties: + - doc: The operation status + apiVersions: + - 1.0-preview.1 + type: &a36 + kind: enum + decorators: [] + name: ResourceProvisioningState + isGeneratedName: false + clientNamespace: Azure.ResourceManager + doc: The provisioning state of a resource type. + valueType: &a35 + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + values: + - kind: enumvalue + decorators: [] + name: Succeeded + doc: Resource has been created. + value: Succeeded + valueType: *a35 + enumType: *a36 + - kind: enumvalue + decorators: [] + name: Failed + doc: Resource creation failed. + value: Failed + valueType: *a35 + enumType: *a36 + - kind: enumvalue + decorators: [] + name: Canceled + doc: Resource creation was canceled. + value: Canceled + valueType: *a35 + enumType: *a36 + isFixed: false + isFlags: false + usage: 4096 + access: public + crossLanguageDefinitionId: Azure.ResourceManager.ResourceProvisioningState + apiVersions: + - 1.0-preview.1 + isUnionAsEnum: true + name: status + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.ArmOperationStatus.status + decorators: [] + kind: property + discriminator: false + serializedName: status + isMultipartFileInput: false + flatten: false + - doc: The unique identifier for the operationStatus resource + apiVersions: + - 1.0-preview.1 + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: id + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.ArmOperationStatus.id + decorators: [] + kind: path + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: id + correspondingMethodParams: [] + - doc: The name of the operationStatus resource + apiVersions: + - 1.0-preview.1 + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: name + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.ArmOperationStatus.name + decorators: [] + kind: property + visibility: + - 1 + discriminator: false + serializedName: name + isMultipartFileInput: false + flatten: false + - doc: Operation start time + apiVersions: + - 1.0-preview.1 + type: + kind: utcDateTime + decorators: [] + name: utcDateTime + encode: rfc3339 + wireType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + doc: An instant in coordinated universal time (UTC)" + crossLanguageDefinitionId: TypeSpec.utcDateTime + name: startTime + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.ArmOperationStatus.startTime + decorators: [] + kind: property + visibility: + - 1 + discriminator: false + serializedName: startTime + isMultipartFileInput: false + flatten: false + - doc: Operation complete time + apiVersions: + - 1.0-preview.1 + type: + kind: utcDateTime + decorators: [] + name: utcDateTime + encode: rfc3339 + wireType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + doc: An instant in coordinated universal time (UTC)" + crossLanguageDefinitionId: TypeSpec.utcDateTime + name: endTime + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.ArmOperationStatus.endTime + decorators: [] + kind: property + visibility: + - 1 + discriminator: false + serializedName: endTime + isMultipartFileInput: false + flatten: false + - doc: The progress made toward completing the operation + apiVersions: + - 1.0-preview.1 + type: + kind: float64 + decorators: [] + name: float64 + doc: A 64 bit floating point number. (`Ā±5.0 Ɨ 10^āˆ’324` to `Ā±1.7 Ɨ 10^308`) + crossLanguageDefinitionId: TypeSpec.float64 + name: percentComplete + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.ArmOperationStatus.percentComplete + decorators: [] + kind: property + visibility: + - 1 + discriminator: false + serializedName: percentComplete + isMultipartFileInput: false + flatten: false + - doc: Errors that occurred if the operation ended with Canceled or Failed status + apiVersions: + - 1.0-preview.1 + type: *a9 + name: error + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.ArmOperationStatus.error + decorators: [] + kind: property + visibility: + - 1 + discriminator: false + serializedName: error + isMultipartFileInput: false + flatten: false + access: public + usage: 4096 + crossLanguageDefinitionId: Azure.ResourceManager.ArmOperationStatus + apiVersions: + - 1.0-preview.1 + - kind: basic + name: update + access: public + parameters: + - &a37 + doc: The name of the resource group. The name is case insensitive. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: resourceGroupName + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.resourceGroupName + decorators: [] + kind: method + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: resourceGroupName + correspondingMethodParams: [] + - &a38 + doc: The name of the Employee + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: employeeName + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.employeeName + decorators: [] + kind: method + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: employeeName + correspondingMethodParams: [] + - &a47 + doc: The resource properties to be updated. + apiVersions: + - 2021-10-01-preview + type: *a25 + name: properties + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.properties + decorators: [] + kind: method + discriminator: false + serializedName: properties + isMultipartFileInput: false + flatten: false + - &a42 + type: &a39 + kind: constant + value: application/json + valueType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: updateContentType + isGeneratedName: true + decorators: [] + name: contentType + isGeneratedName: true + apiVersions: &a40 + - 2021-10-01-preview + isApiVersionParam: false + onClient: false + optional: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.Employees.update.contentType + decorators: &a41 [] + doc: Body parameter's content type. Known values are application/json + kind: method + - &a46 + type: &a43 + kind: constant + value: application/json + valueType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: updateContentType + isGeneratedName: true + decorators: [] + name: accept + isGeneratedName: true + apiVersions: &a44 + - 2021-10-01-preview + isApiVersionParam: false + onClient: false + optional: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.Employees.update.accept + decorators: &a45 [] + kind: method + doc: Update a Employee + operation: + kind: http + path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContosoProviderHub/employees/{employeeName} + uriTemplate: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContosoProviderHub/employees/{employeeName}{?api-version} + verb: patch + parameters: + - doc: The API version to use for this operation. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: apiVersion + isGeneratedName: false + optional: false + isApiVersionParam: true + clientDefaultValue: 2021-10-01-preview + onClient: true + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.apiVersion + decorators: [] + correspondingMethodParams: + - *a26 + kind: query + serializedName: api-version + explode: false + - doc: The ID of the target subscription. The value must be an UUID. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: uuid + doc: Universally Unique Identifier + baseType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + crossLanguageDefinitionId: Azure.Core.uuid + name: subscriptionId + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: true + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.subscriptionId + decorators: [] + kind: path + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: subscriptionId + correspondingMethodParams: + - *a27 + - doc: The name of the resource group. The name is case insensitive. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: resourceGroupName + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.resourceGroupName + decorators: [] + kind: path + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: resourceGroupName + correspondingMethodParams: + - *a37 + - doc: The name of the Employee + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: employeeName + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.employeeName + decorators: [] + kind: path + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: employeeName + correspondingMethodParams: + - *a38 + - type: *a39 + name: contentType + isGeneratedName: true + apiVersions: *a40 + isApiVersionParam: false + onClient: false + optional: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.Employees.update.contentType + decorators: *a41 + doc: Body parameter's content type. Known values are application/json + kind: header + serializedName: Content-Type + correspondingMethodParams: + - *a42 + - type: *a43 + name: accept + isGeneratedName: true + apiVersions: *a44 + isApiVersionParam: false + onClient: false + optional: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.Employees.update.accept + decorators: *a45 + kind: header + serializedName: Accept + correspondingMethodParams: + - *a46 + bodyParam: + doc: The resource properties to be updated. + apiVersions: *a40 + type: *a25 + name: properties + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.properties + decorators: [] + kind: body + serializedName: properties + contentTypes: + - application/json + defaultContentType: application/json + correspondingMethodParams: + - *a47 + responses: + - type: *a25 + headers: [] + contentTypes: + - application/json + defaultContentType: application/json + apiVersions: *a44 + description: Azure operation completed successfully. + kind: http + statusCodes: 200 + exceptions: + - type: *a24 + headers: [] + contentTypes: + - application/json + defaultContentType: application/json + apiVersions: + - 2021-10-01-preview + kind: http + statusCodes: "*" + response: + kind: method + type: *a25 + apiVersions: + - 2021-10-01-preview + crossLanguageDefintionId: Microsoft.ContosoProviderHub.Employees.update + decorators: [] + generateConvenient: true + generateProtocol: true + isOverride: false + - kind: lro + name: delete + access: public + parameters: + - &a48 + doc: The name of the resource group. The name is case insensitive. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: resourceGroupName + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.resourceGroupName + decorators: [] + kind: method + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: resourceGroupName + correspondingMethodParams: [] + - &a49 + doc: The name of the Employee + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: employeeName + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.employeeName + decorators: [] + kind: method + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: employeeName + correspondingMethodParams: [] + - &a50 + type: + kind: constant + value: application/json + valueType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: deleteContentType + isGeneratedName: true + decorators: [] + name: accept + isGeneratedName: true + apiVersions: + - 2021-10-01-preview + isApiVersionParam: false + onClient: false + optional: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.Employees.delete.accept + decorators: [] + kind: method + doc: Delete a Employee + operation: + kind: http + path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContosoProviderHub/employees/{employeeName} + uriTemplate: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContosoProviderHub/employees/{employeeName}{?api-version} + verb: delete + parameters: + - doc: The API version to use for this operation. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: apiVersion + isGeneratedName: false + optional: false + isApiVersionParam: true + clientDefaultValue: 2021-10-01-preview + onClient: true + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.apiVersion + decorators: [] + correspondingMethodParams: + - *a26 + kind: query + serializedName: api-version + explode: false + - doc: The ID of the target subscription. The value must be an UUID. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: uuid + doc: Universally Unique Identifier + baseType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + crossLanguageDefinitionId: Azure.Core.uuid + name: subscriptionId + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: true + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.subscriptionId + decorators: [] + kind: path + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: subscriptionId + correspondingMethodParams: + - *a27 + - doc: The name of the resource group. The name is case insensitive. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: resourceGroupName + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.resourceGroupName + decorators: [] + kind: path + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: resourceGroupName + correspondingMethodParams: + - *a48 + - doc: The name of the Employee + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: employeeName + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.employeeName + decorators: [] + kind: path + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: employeeName + correspondingMethodParams: + - *a49 + - type: + kind: constant + value: application/json + valueType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: deleteContentType + isGeneratedName: true + decorators: [] + name: accept + isGeneratedName: true + apiVersions: &a51 + - 2021-10-01-preview + isApiVersionParam: false + onClient: false + optional: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.Employees.delete.accept + decorators: [] + kind: header + serializedName: Accept + correspondingMethodParams: + - *a50 + responses: + - headers: + - doc: The Location header contains the URL where the status of the long running operation can be checked. + serializedName: Location + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + - doc: The Retry-After header can indicate how long the client should wait before polling the operation status. + serializedName: Retry-After + type: + kind: int32 + decorators: [] + name: int32 + doc: A 32-bit integer. (`-2,147,483,648` to `2,147,483,647`) + crossLanguageDefinitionId: TypeSpec.int32 + apiVersions: + - 2021-10-01-preview + description: Resource deletion accepted. + kind: http + statusCodes: 202 + - headers: [] + apiVersions: + - 2021-10-01-preview + description: Resource does not exist. + kind: http + statusCodes: 204 + exceptions: + - type: *a24 + headers: [] + contentTypes: + - application/json + defaultContentType: application/json + apiVersions: *a51 + kind: http + statusCodes: "*" + response: + kind: method + apiVersions: + - 2021-10-01-preview + crossLanguageDefintionId: Microsoft.ContosoProviderHub.Employees.delete + decorators: [] + generateConvenient: true + generateProtocol: true + isOverride: false + lroMetadata: + finalStateVia: location + finalStep: + kind: finalOperationLink + pollingStep: + responseBody: *a52 + - kind: paging + name: listByResourceGroup + access: public + parameters: + - &a53 + doc: The name of the resource group. The name is case insensitive. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: resourceGroupName + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.resourceGroupName + decorators: [] + kind: method + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: resourceGroupName + correspondingMethodParams: [] + - &a57 + type: &a54 + kind: constant + value: application/json + valueType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: listByResourceGroupContentType + isGeneratedName: true + decorators: [] + name: accept + isGeneratedName: true + apiVersions: &a55 + - 2021-10-01-preview + isApiVersionParam: false + onClient: false + optional: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.Employees.listByResourceGroup.accept + decorators: &a56 [] + kind: method + doc: List Employee resources by resource group + operation: + kind: http + path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContosoProviderHub/employees + uriTemplate: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContosoProviderHub/employees{?api-version} + verb: get + parameters: + - doc: The API version to use for this operation. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: apiVersion + isGeneratedName: false + optional: false + isApiVersionParam: true + clientDefaultValue: 2021-10-01-preview + onClient: true + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.apiVersion + decorators: [] + correspondingMethodParams: + - *a26 + kind: query + serializedName: api-version + explode: false + - doc: The ID of the target subscription. The value must be an UUID. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: uuid + doc: Universally Unique Identifier + baseType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + crossLanguageDefinitionId: Azure.Core.uuid + name: subscriptionId + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: true + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.subscriptionId + decorators: [] + kind: path + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: subscriptionId + correspondingMethodParams: + - *a27 + - doc: The name of the resource group. The name is case insensitive. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: resourceGroupName + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.resourceGroupName + decorators: [] + kind: path + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: resourceGroupName + correspondingMethodParams: + - *a53 + - type: *a54 + name: accept + isGeneratedName: true + apiVersions: *a55 + isApiVersionParam: false + onClient: false + optional: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.Employees.listByResourceGroup.accept + decorators: *a56 + kind: header + serializedName: Accept + correspondingMethodParams: + - *a57 + responses: + - type: &a62 + kind: model + decorators: [] + name: EmployeeListResult + isGeneratedName: false + clientNamespace: Azure.ResourceManager + doc: The response of a Employee list operation. + properties: + - doc: The Employee items on this page + apiVersions: + - 1.0-preview.1 + - 1.0-preview.2 + type: + kind: array + decorators: [] + name: ArrayEmployee + valueType: *a25 + crossLanguageDefinitionId: TypeSpec.Array + name: value + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.ResourceListResult.value + decorators: [] + kind: property + discriminator: false + serializedName: value + isMultipartFileInput: false + flatten: false + - doc: The link to the next page of items + apiVersions: + - 1.0-preview.1 + - 1.0-preview.2 + type: + kind: url + decorators: [] + name: ResourceLocation + doc: The location of an instance of Employee + baseType: + kind: url + decorators: [] + name: url + doc: Represent a URL string as described by https://url.spec.whatwg.org/ + crossLanguageDefinitionId: TypeSpec.url + crossLanguageDefinitionId: TypeSpec.Rest.ResourceLocation + name: nextLink + isGeneratedName: false + optional: true + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Azure.ResourceManager.ResourceListResult.nextLink + decorators: [] + kind: property + discriminator: false + serializedName: nextLink + isMultipartFileInput: false + flatten: false + access: public + usage: 260 + crossLanguageDefinitionId: Azure.ResourceManager.ResourceListResult + apiVersions: + - 1.0-preview.1 + headers: [] + contentTypes: + - application/json + defaultContentType: application/json + apiVersions: *a55 + description: Azure operation completed successfully. + kind: http + statusCodes: 200 + exceptions: + - type: *a24 + headers: [] + contentTypes: + - application/json + defaultContentType: application/json + apiVersions: + - 2021-10-01-preview + kind: http + statusCodes: "*" + response: + kind: method + type: + kind: array + decorators: [] + name: ArrayEmployee + valueType: *a25 + crossLanguageDefinitionId: TypeSpec.Array + resultPath: value + apiVersions: + - 2021-10-01-preview + crossLanguageDefintionId: Microsoft.ContosoProviderHub.Employees.listByResourceGroup + decorators: [] + generateConvenient: true + generateProtocol: true + isOverride: false + nextLinkPath: nextLink + - kind: paging + name: listBySubscription + access: public + parameters: + - &a61 + type: &a58 + kind: constant + value: application/json + valueType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: listBySubscriptionContentType + isGeneratedName: true + decorators: [] + name: accept + isGeneratedName: true + apiVersions: &a59 + - 2021-10-01-preview + isApiVersionParam: false + onClient: false + optional: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.Employees.listBySubscription.accept + decorators: &a60 [] + kind: method + doc: List Employee resources by subscription ID + operation: + kind: http + path: /subscriptions/{subscriptionId}/providers/Microsoft.ContosoProviderHub/employees + uriTemplate: /subscriptions/{subscriptionId}/providers/Microsoft.ContosoProviderHub/employees{?api-version} + verb: get + parameters: + - doc: The API version to use for this operation. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: apiVersion + isGeneratedName: false + optional: false + isApiVersionParam: true + clientDefaultValue: 2021-10-01-preview + onClient: true + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.apiVersion + decorators: [] + correspondingMethodParams: + - *a26 + kind: query + serializedName: api-version + explode: false + - doc: The ID of the target subscription. The value must be an UUID. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: uuid + doc: Universally Unique Identifier + baseType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + crossLanguageDefinitionId: Azure.Core.uuid + name: subscriptionId + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: true + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.subscriptionId + decorators: [] + kind: path + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: subscriptionId + correspondingMethodParams: + - *a27 + - type: *a58 + name: accept + isGeneratedName: true + apiVersions: *a59 + isApiVersionParam: false + onClient: false + optional: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.Employees.listBySubscription.accept + decorators: *a60 + kind: header + serializedName: Accept + correspondingMethodParams: + - *a61 + responses: + - type: *a62 + headers: [] + contentTypes: + - application/json + defaultContentType: application/json + apiVersions: *a59 + description: Azure operation completed successfully. + kind: http + statusCodes: 200 + exceptions: + - type: *a24 + headers: [] + contentTypes: + - application/json + defaultContentType: application/json + apiVersions: + - 2021-10-01-preview + kind: http + statusCodes: "*" + response: + kind: method + type: + kind: array + decorators: [] + name: ArrayEmployee + valueType: *a25 + crossLanguageDefinitionId: TypeSpec.Array + resultPath: value + apiVersions: + - 2021-10-01-preview + crossLanguageDefintionId: Microsoft.ContosoProviderHub.Employees.listBySubscription + decorators: [] + generateConvenient: true + generateProtocol: true + isOverride: false + nextLinkPath: nextLink + - kind: basic + name: move + access: public + parameters: + - &a63 + doc: The name of the resource group. The name is case insensitive. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: resourceGroupName + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.resourceGroupName + decorators: [] + kind: method + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: resourceGroupName + correspondingMethodParams: [] + - &a64 + doc: The name of the Employee + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: employeeName + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.employeeName + decorators: [] + kind: method + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: employeeName + correspondingMethodParams: [] + - &a74 + doc: The content of the action request + apiVersions: + - 2021-10-01-preview + type: &a73 + kind: model + decorators: [] + name: MoveRequest + isGeneratedName: false + clientNamespace: Microsoft.ContosoProviderHub + doc: Employee move request + properties: + - doc: The moving from location + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: from + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.MoveRequest.from + decorators: [] + kind: property + discriminator: false + serializedName: from + isMultipartFileInput: false + flatten: false + - doc: The moving to location + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: to + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.MoveRequest.to + decorators: [] + kind: property + discriminator: false + serializedName: to + isMultipartFileInput: false + flatten: false + access: public + usage: 258 + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.MoveRequest + apiVersions: + - 2021-10-01-preview + name: body + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.body + decorators: [] + kind: method + discriminator: false + serializedName: body + isMultipartFileInput: false + flatten: false + - &a68 + type: &a65 + kind: constant + value: application/json + valueType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: moveContentType + isGeneratedName: true + decorators: [] + name: contentType + isGeneratedName: true + apiVersions: &a66 + - 2021-10-01-preview + isApiVersionParam: false + onClient: false + optional: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.Employees.move.contentType + decorators: &a67 [] + doc: Body parameter's content type. Known values are application/json + kind: method + - &a72 + type: &a69 + kind: constant + value: application/json + valueType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: moveContentType + isGeneratedName: true + decorators: [] + name: accept + isGeneratedName: true + apiVersions: &a70 + - 2021-10-01-preview + isApiVersionParam: false + onClient: false + optional: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.Employees.move.accept + decorators: &a71 [] + kind: method + doc: A sample resource action that move employee to different location + operation: + kind: http + path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContosoProviderHub/employees/{employeeName}/move + uriTemplate: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContosoProviderHub/employees/{employeeName}/move{?api-version} + verb: post + parameters: + - doc: The API version to use for this operation. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: apiVersion + isGeneratedName: false + optional: false + isApiVersionParam: true + clientDefaultValue: 2021-10-01-preview + onClient: true + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.apiVersion + decorators: [] + correspondingMethodParams: + - *a26 + kind: query + serializedName: api-version + explode: false + - doc: The ID of the target subscription. The value must be an UUID. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: uuid + doc: Universally Unique Identifier + baseType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + crossLanguageDefinitionId: Azure.Core.uuid + name: subscriptionId + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: true + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.subscriptionId + decorators: [] + kind: path + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: subscriptionId + correspondingMethodParams: + - *a27 + - doc: The name of the resource group. The name is case insensitive. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: resourceGroupName + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.resourceGroupName + decorators: [] + kind: path + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: resourceGroupName + correspondingMethodParams: + - *a63 + - doc: The name of the Employee + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: employeeName + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.employeeName + decorators: [] + kind: path + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: employeeName + correspondingMethodParams: + - *a64 + - type: *a65 + name: contentType + isGeneratedName: true + apiVersions: *a66 + isApiVersionParam: false + onClient: false + optional: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.Employees.move.contentType + decorators: *a67 + doc: Body parameter's content type. Known values are application/json + kind: header + serializedName: Content-Type + correspondingMethodParams: + - *a68 + - type: *a69 + name: accept + isGeneratedName: true + apiVersions: *a70 + isApiVersionParam: false + onClient: false + optional: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.Employees.move.accept + decorators: *a71 + kind: header + serializedName: Accept + correspondingMethodParams: + - *a72 + bodyParam: + doc: The content of the action request + apiVersions: *a66 + type: *a73 + name: body + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.body + decorators: [] + kind: body + serializedName: body + contentTypes: + - application/json + defaultContentType: application/json + correspondingMethodParams: + - *a74 + responses: + - type: &a75 + kind: model + decorators: [] + name: MoveResponse + isGeneratedName: false + clientNamespace: Microsoft.ContosoProviderHub + doc: Employee move response + properties: + - doc: The status of the move + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: movingStatus + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.MoveResponse.movingStatus + decorators: [] + kind: property + discriminator: false + serializedName: movingStatus + isMultipartFileInput: false + flatten: false + access: public + usage: 260 + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.MoveResponse + apiVersions: + - 2021-10-01-preview + headers: [] + contentTypes: + - application/json + defaultContentType: application/json + apiVersions: *a70 + description: Azure operation completed successfully. + kind: http + statusCodes: 200 + exceptions: + - type: *a24 + headers: [] + contentTypes: + - application/json + defaultContentType: application/json + apiVersions: + - 2021-10-01-preview + kind: http + statusCodes: "*" + response: + kind: method + type: *a75 + apiVersions: + - 2021-10-01-preview + crossLanguageDefintionId: Microsoft.ContosoProviderHub.Employees.move + decorators: [] + generateConvenient: true + generateProtocol: true + isOverride: false + - kind: basic + name: checkExistence + access: public + parameters: + - &a76 + doc: The name of the resource group. The name is case insensitive. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: resourceGroupName + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.resourceGroupName + decorators: [] + kind: method + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: resourceGroupName + correspondingMethodParams: [] + - &a77 + doc: The name of the Employee + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: employeeName + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.employeeName + decorators: [] + kind: method + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: employeeName + correspondingMethodParams: [] + - &a81 + type: &a78 + kind: constant + value: application/json + valueType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: checkExistenceContentType + isGeneratedName: true + decorators: [] + name: accept + isGeneratedName: true + apiVersions: &a79 + - 2021-10-01-preview + isApiVersionParam: false + onClient: false + optional: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.Employees.checkExistence.accept + decorators: &a80 [] + kind: method + doc: A sample HEAD operation to check resource existence + operation: + kind: http + path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContosoProviderHub/employees/{employeeName} + uriTemplate: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContosoProviderHub/employees/{employeeName}{?api-version} + verb: head + parameters: + - doc: The API version to use for this operation. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: apiVersion + isGeneratedName: false + optional: false + isApiVersionParam: true + clientDefaultValue: 2021-10-01-preview + onClient: true + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.apiVersion + decorators: [] + correspondingMethodParams: + - *a26 + kind: query + serializedName: api-version + explode: false + - doc: The ID of the target subscription. The value must be an UUID. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: uuid + doc: Universally Unique Identifier + baseType: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + crossLanguageDefinitionId: Azure.Core.uuid + name: subscriptionId + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: true + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.subscriptionId + decorators: [] + kind: path + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: subscriptionId + correspondingMethodParams: + - *a27 + - doc: The name of the resource group. The name is case insensitive. + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: resourceGroupName + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.resourceGroupName + decorators: [] + kind: path + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: resourceGroupName + correspondingMethodParams: + - *a76 + - doc: The name of the Employee + apiVersions: + - 2021-10-01-preview + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + name: employeeName + isGeneratedName: false + optional: false + isApiVersionParam: false + onClient: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub..anonymous.employeeName + decorators: [] + kind: path + urlEncode: true + explode: false + style: simple + allowReserved: false + serializedName: employeeName + correspondingMethodParams: + - *a77 + - type: *a78 + name: accept + isGeneratedName: true + apiVersions: *a79 + isApiVersionParam: false + onClient: false + optional: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.Employees.checkExistence.accept + decorators: *a80 + kind: header + serializedName: Accept + correspondingMethodParams: + - *a81 + responses: + - headers: [] + apiVersions: + - 2021-10-01-preview + description: The Azure resource exists + kind: http + statusCodes: 204 + - headers: [] + apiVersions: + - 2021-10-01-preview + description: The Azure resource is not found + kind: http + statusCodes: 404 + exceptions: + - type: *a24 + headers: [] + contentTypes: + - application/json + defaultContentType: application/json + apiVersions: *a79 + kind: http + statusCodes: "*" + response: + kind: method + apiVersions: + - 2021-10-01-preview + crossLanguageDefintionId: Microsoft.ContosoProviderHub.Employees.checkExistence + decorators: [] + generateConvenient: true + generateProtocol: true + isOverride: false + apiVersions: &a82 + - 2021-10-01-preview + nameSpace: Microsoft.ContosoProviderHub + clientNamespace: Microsoft.ContosoProviderHub + initialization: + doc: Initialization class for the client + kind: model + properties: + - kind: endpoint + type: + kind: endpoint + serverUrl: "{endpoint}" + templateArguments: + - name: endpoint + isGeneratedName: true + doc: Service host + kind: path + onClient: true + urlEncode: false + explode: false + style: simple + allowReserved: false + optional: false + serializedName: endpoint + correspondingMethodParams: [] + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + isApiVersionParam: false + apiVersions: *a82 + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.endpoint + decorators: [] + clientDefaultValue: https://management.azure.com + decorators: [] + name: endpoint + isGeneratedName: true + doc: Service host + onClient: true + urlEncode: false + apiVersions: *a82 + optional: false + isApiVersionParam: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.endpoint + decorators: [] + - type: + kind: credential + decorators: [] + kind: credential + name: credential + isGeneratedName: true + doc: Credential used to authenticate requests to the service. + apiVersions: &a83 + - 2021-10-01-preview + onClient: true + optional: false + isApiVersionParam: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.credential + decorators: [] + - *a26 + - *a27 + name: EmployeesOptions + isGeneratedName: true + access: internal + usage: 2 + crossLanguageDefinitionId: Microsoft.EmployeesOptions + clientNamespace: Microsoft.ContosoProviderHub + apiVersions: *a82 + decorators: [] + decorators: [] + parent: *a13 + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.Employees + apiVersions: + - 2021-10-01-preview + crossLanguageDefintionId: Microsoft.ContosoProviderHub.Employees + decorators: [] + apiVersions: &a84 + - 2021-10-01-preview + nameSpace: Microsoft.ContosoProviderHub + clientNamespace: Microsoft.ContosoProviderHub + initialization: + doc: Initialization class for the client + kind: model + properties: + - kind: endpoint + type: + kind: endpoint + serverUrl: "{endpoint}" + templateArguments: + - name: endpoint + isGeneratedName: true + doc: Service host + kind: path + onClient: true + urlEncode: false + explode: false + style: simple + allowReserved: false + optional: false + serializedName: endpoint + correspondingMethodParams: [] + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + isApiVersionParam: false + apiVersions: *a83 + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.endpoint + decorators: [] + clientDefaultValue: https://management.azure.com + decorators: [] + name: endpoint + isGeneratedName: true + doc: Service host + onClient: true + urlEncode: false + apiVersions: *a83 + optional: false + isApiVersionParam: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.endpoint + decorators: [] + - type: + kind: credential + decorators: [] + kind: credential + name: credential + isGeneratedName: true + doc: Credential used to authenticate requests to the service. + apiVersions: + - 2021-10-01-preview + onClient: true + optional: false + isApiVersionParam: false + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.credential + decorators: [] + - *a12 + - *a27 + name: ContosoProviderHubClientOptions + isGeneratedName: true + access: public + usage: 2 + crossLanguageDefinitionId: Microsoft.ContosoProviderHubClientOptions + clientNamespace: Microsoft.ContosoProviderHub + apiVersions: *a84 + decorators: [] + decorators: [] + crossLanguageDefinitionId: Microsoft.ContosoProviderHub +models: + - *a25 + - *a85 + - *a86 + - *a87 + - *a88 + - *a24 + - *a9 + - *a89 + - *a90 + - *a52 + - *a62 + - *a73 + - *a75 + - *a91 + - *a10 + - *a92 +enums: + - *a21 + - *a23 + - *a36 + - *a6 + - *a8 + - &a93 + kind: enum + decorators: [] + name: Versions + isGeneratedName: false + clientNamespace: Microsoft.ContosoProviderHub + doc: Contoso API versions + valueType: &a94 + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + values: + - kind: enumvalue + decorators: [] + name: 2021-10-01-preview + value: 2021-10-01-preview + doc: 2021-10-01-preview version + enumType: *a93 + valueType: *a94 + isFixed: true + isFlags: false + usage: 8 + access: public + crossLanguageDefinitionId: Microsoft.ContosoProviderHub.Versions + apiVersions: + - 2021-10-01-preview + isUnionAsEnum: false +unions: [] +crossLanguagePackageId: Microsoft.ContosoProviderHub +namespaces: + - name: Microsoft + fullName: Microsoft + clients: [] + models: [] + enums: [] + unions: [] + namespaces: + - name: ContosoProviderHub + fullName: Microsoft.ContosoProviderHub + clients: + - *a13 + - *a95 + - *a96 + models: + - *a25 + - *a85 + - *a73 + - *a75 + enums: + - *a21 + - *a93 + unions: [] + namespaces: [] + - name: Azure + fullName: Azure + clients: [] + models: [] + enums: [] + unions: [] + namespaces: + - name: ResourceManager + fullName: Azure.ResourceManager + clients: [] + models: + - *a52 + - *a62 + enums: + - *a36 + unions: [] + namespaces: + - name: CommonTypes + fullName: Azure.ResourceManager.CommonTypes + clients: [] + models: + - *a86 + - *a87 + - *a88 + - *a24 + - *a9 + - *a89 + - *a90 + - *a91 + - *a10 + - *a92 + enums: + - *a23 + - *a6 + - *a8 + unions: [] + namespaces: [] diff --git a/packages/typespec-client-generator-core/test/context/output/tcgc-output.yaml b/packages/typespec-client-generator-core/test/context/output/tcgc-output.yaml new file mode 100644 index 0000000000..c695b0a526 --- /dev/null +++ b/packages/typespec-client-generator-core/test/context/output/tcgc-output.yaml @@ -0,0 +1,94 @@ +name: Contoso.WidgetManager +rootNamespace: Contoso.WidgetManager +clients: + - &a2 + kind: client + name: WidgetManagerClient + methods: [] + apiVersions: &a1 [] + nameSpace: Contoso.WidgetManager + clientNamespace: Contoso.WidgetManager + initialization: + doc: Initialization class for the client + kind: model + properties: + - kind: endpoint + type: + kind: endpoint + serverUrl: "{endpoint}" + templateArguments: + - name: endpoint + isGeneratedName: true + doc: Service host + kind: path + onClient: true + urlEncode: false + explode: false + style: simple + allowReserved: false + optional: false + serializedName: endpoint + correspondingMethodParams: [] + type: + kind: string + decorators: [] + name: string + doc: A sequence of textual characters. + crossLanguageDefinitionId: TypeSpec.string + isApiVersionParam: false + apiVersions: *a1 + crossLanguageDefinitionId: Contoso.WidgetManager.endpoint + decorators: [] + decorators: [] + name: endpoint + isGeneratedName: true + doc: Service host + onClient: true + urlEncode: false + apiVersions: *a1 + optional: false + isApiVersionParam: false + crossLanguageDefinitionId: Contoso.WidgetManager.endpoint + decorators: [] + name: WidgetManagerClientOptions + isGeneratedName: true + access: public + usage: 2 + crossLanguageDefinitionId: Contoso.WidgetManagerClientOptions + clientNamespace: Contoso.WidgetManager + apiVersions: *a1 + decorators: [] + decorators: [] + crossLanguageDefinitionId: Contoso.WidgetManager +models: + - &a3 + kind: model + decorators: [] + name: Test + isGeneratedName: false + clientNamespace: Contoso.WidgetManager + properties: [] + access: public + usage: 2 + crossLanguageDefinitionId: Contoso.WidgetManager.Test + apiVersions: [] +enums: [] +unions: [] +crossLanguagePackageId: Contoso.WidgetManager +namespaces: + - name: Contoso + fullName: Contoso + clients: [] + models: [] + enums: [] + unions: [] + namespaces: + - name: WidgetManager + fullName: Contoso.WidgetManager + clients: + - *a2 + models: + - *a3 + enums: [] + unions: [] + namespaces: [] diff --git a/packages/typespec-client-generator-core/test/decorators.test.ts b/packages/typespec-client-generator-core/test/decorators.test.ts index 3e887eb23f..00d2076345 100644 --- a/packages/typespec-client-generator-core/test/decorators.test.ts +++ b/packages/typespec-client-generator-core/test/decorators.test.ts @@ -3,7 +3,6 @@ import { expectDiagnostics } from "@typespec/compiler/testing"; import { deepStrictEqual, ok, strictEqual } from "assert"; import { beforeEach, describe, it } from "vitest"; import { - createSdkContext, getAccess, getClient, getClientNameOverride, @@ -2194,40 +2193,6 @@ describe("typespec-client-generator-core: decorators", () => { }); }); - describe("createSdkContext", () => { - it("multiple call with versioning", async () => { - const tsp = ` - @service({ - title: "Contoso Widget Manager", - }) - @versioned(Contoso.WidgetManager.Versions) - namespace Contoso.WidgetManager; - - enum Versions { - v1, - } - - @client({name: "TestClient"}) - @test - interface Test {} - `; - - const runnerWithVersion = await createSdkTestRunner({ - emitterName: "@azure-tools/typespec-python", - }); - - await runnerWithVersion.compile(tsp); - let clients = listClients(runnerWithVersion.context); - strictEqual(clients.length, 1); - ok(clients[0].type); - - const newSdkContext = await createSdkContext(runnerWithVersion.context.emitContext); - clients = listClients(newSdkContext); - strictEqual(clients.length, 1); - ok(clients[0].type); - }); - }); - describe("@clientInitialization", () => { it("main client", async () => { await runner.compileWithCustomization( diff --git a/packages/typespec-client-generator-core/test/public-utils.test.ts b/packages/typespec-client-generator-core/test/public-utils.test.ts index 4ec7f27846..cc72670c8e 100644 --- a/packages/typespec-client-generator-core/test/public-utils.test.ts +++ b/packages/typespec-client-generator-core/test/public-utils.test.ts @@ -24,12 +24,7 @@ import { isAzureCoreModel, } from "../src/public-utils.js"; import { getAllModels, getSdkUnion } from "../src/types.js"; -import { - SdkTestRunner, - createSdkContextTestHelper, - createSdkTestRunner, - createTcgcTestRunnerForEmitter, -} from "./test-host.js"; +import { SdkTestRunner, createSdkContextTestHelper, createSdkTestRunner } from "./test-host.js"; describe("typespec-client-generator-core: public-utils", () => { let runner: SdkTestRunner; @@ -402,7 +397,7 @@ describe("typespec-client-generator-core: public-utils", () => { describe("getPropertyNames", () => { it("property language projected name", async () => { async function helper(emitterName: string, expectedLibraryName: string) { - const runner = await createTcgcTestRunnerForEmitter(emitterName); + const runner = await createSdkTestRunner({ emitterName }); const { MyModel } = (await runner.compile(` @test model MyModel { @@ -428,7 +423,7 @@ describe("typespec-client-generator-core: public-utils", () => { }); it("property language projected name augmented", async () => { async function helper(emitterName: string, expectedLibraryName: string) { - const runner = await createTcgcTestRunnerForEmitter(emitterName); + const runner = await createSdkTestRunner({ emitterName }); const { MyModel } = (await runner.compile(` @test model MyModel { @@ -453,7 +448,7 @@ describe("typespec-client-generator-core: public-utils", () => { }); it("property client projected name", async () => { async function helper(emitterName: string) { - const runner = await createTcgcTestRunnerForEmitter(emitterName); + const runner = await createSdkTestRunner({ emitterName }); const { MyModel } = (await runner.compile(` @test model MyModel { @@ -475,7 +470,7 @@ describe("typespec-client-generator-core: public-utils", () => { }); it("property no projected name", async () => { async function helper(emitterName: string) { - const runner = await createTcgcTestRunnerForEmitter(emitterName); + const runner = await createSdkTestRunner({ emitterName }); const { MyModel } = (await runner.compile(` @test model MyModel { @@ -494,7 +489,7 @@ describe("typespec-client-generator-core: public-utils", () => { }); it("property with projected client and json name", async () => { async function helper(emitterName: string, expectedLibraryName: string) { - const runner = await createTcgcTestRunnerForEmitter(emitterName); + const runner = await createSdkTestRunner({ emitterName }); const { MyModel } = (await runner.compile(` @test model MyModel { @@ -521,7 +516,7 @@ describe("typespec-client-generator-core: public-utils", () => { }); it("property with projected language and json name", async () => { async function helper(emitterName: string) { - const runner = await createTcgcTestRunnerForEmitter(emitterName); + const runner = await createSdkTestRunner({ emitterName }); const { MyModel } = (await runner.compile(` @test model MyModel { @@ -544,7 +539,7 @@ describe("typespec-client-generator-core: public-utils", () => { describe("getLibraryName", () => { it("operation client projected name", async () => { async function helper(emitterName: string) { - const runner = await createTcgcTestRunnerForEmitter(emitterName); + const runner = await createSdkTestRunner({ emitterName }); const { func } = (await runner.compile(` @test @clientName("rightName") op func(@query("api-version") myApiVersion: string): void; `)) as { func: Operation }; @@ -557,7 +552,7 @@ describe("typespec-client-generator-core: public-utils", () => { }); it("operation language projected name", async () => { async function helper(emitterName: string, expected: string) { - const runner = await createTcgcTestRunnerForEmitter(emitterName); + const runner = await createSdkTestRunner({ emitterName }); const { func } = (await runner.compile(` @test @clientName("madeForCS", "csharp") @@ -575,7 +570,7 @@ describe("typespec-client-generator-core: public-utils", () => { }); it("operation language projected name augmented", async () => { async function helper(emitterName: string, expected: string) { - const runner = await createTcgcTestRunnerForEmitter(emitterName); + const runner = await createSdkTestRunner({ emitterName }); const { func } = (await runner.compile(` @test op func(@query("api-version") myApiVersion: string): void; @@ -594,7 +589,7 @@ describe("typespec-client-generator-core: public-utils", () => { }); it("operation json projected name", async () => { async function helper(emitterName: string) { - const runner = await createTcgcTestRunnerForEmitter(emitterName); + const runner = await createSdkTestRunner({ emitterName }); const { func } = (await runner.compile(` @test @encodedName("application/json", "NotToUseMeAsName") // Should be ignored @@ -609,7 +604,7 @@ describe("typespec-client-generator-core: public-utils", () => { }); it("operation no projected name", async () => { async function helper(emitterName: string) { - const runner = await createTcgcTestRunnerForEmitter(emitterName); + const runner = await createSdkTestRunner({ emitterName }); const { func } = (await runner.compile(` @test op func(@query("api-version") myApiVersion: string): void; @@ -623,7 +618,7 @@ describe("typespec-client-generator-core: public-utils", () => { }); it("model client projected name", async () => { async function helper(emitterName: string) { - const runner = await createTcgcTestRunnerForEmitter(emitterName); + const runner = await createSdkTestRunner({ emitterName }); const { MyModel } = (await runner.compile(` @test @clientName("RightName") @@ -640,7 +635,7 @@ describe("typespec-client-generator-core: public-utils", () => { }); it("model language projected name", async () => { async function helper(emitterName: string, expected: string) { - const runner = await createTcgcTestRunnerForEmitter(emitterName); + const runner = await createSdkTestRunner({ emitterName }); const { MyModel } = (await runner.compile(` @test @clientName("CsharpModel", "csharp") @@ -660,7 +655,7 @@ describe("typespec-client-generator-core: public-utils", () => { }); it("model language projected name augmented", async () => { async function helper(emitterName: string, expected: string) { - const runner = await createTcgcTestRunnerForEmitter(emitterName); + const runner = await createSdkTestRunner({ emitterName }); const { MyModel } = (await runner.compile(` @test model MyModel { @@ -681,7 +676,7 @@ describe("typespec-client-generator-core: public-utils", () => { }); it("model json projected name", async () => { async function helper(emitterName: string) { - const runner = await createTcgcTestRunnerForEmitter(emitterName); + const runner = await createSdkTestRunner({ emitterName }); const { MyModel } = (await runner.compile(` @test @encodedName("application/json", "NotToUseMeAsName") // Should be ignored @@ -698,7 +693,7 @@ describe("typespec-client-generator-core: public-utils", () => { }); it("model no projected name", async () => { async function helper(emitterName: string) { - const runner = await createTcgcTestRunnerForEmitter(emitterName); + const runner = await createSdkTestRunner({ emitterName }); const { MyModel } = (await runner.compile(` @test model MyModel { @@ -714,7 +709,7 @@ describe("typespec-client-generator-core: public-utils", () => { }); it("model friendly name", async () => { async function helper(emitterName: string) { - const runner = await createTcgcTestRunnerForEmitter(emitterName); + const runner = await createSdkTestRunner({ emitterName }); const { MyModel } = (await runner.compile(` @test @friendlyName("FriendlyName") @@ -731,7 +726,7 @@ describe("typespec-client-generator-core: public-utils", () => { }); it("model friendly name augmented", async () => { async function helper(emitterName: string) { - const runner = await createTcgcTestRunnerForEmitter(emitterName); + const runner = await createSdkTestRunner({ emitterName }); const { MyModel } = (await runner.compile(` @test model MyModel { @@ -749,7 +744,7 @@ describe("typespec-client-generator-core: public-utils", () => { it("should return language specific name when both language specific name and friendly name exist", async () => { async function helper(expected: string, emitterName: string) { - const runner = await createTcgcTestRunnerForEmitter(emitterName); + const runner = await createSdkTestRunner({ emitterName }); const { MyModel } = (await runner.compile(` @test @friendlyName("FriendlyName") @@ -771,7 +766,7 @@ describe("typespec-client-generator-core: public-utils", () => { it("should return client name when both client name and friendly name exist", async () => { async function helper(expected: string, emitterName: string) { - const runner = await createTcgcTestRunnerForEmitter(emitterName); + const runner = await createSdkTestRunner({ emitterName }); const { MyModel } = (await runner.compile(` @test @friendlyName("FriendlyName") @@ -790,7 +785,7 @@ describe("typespec-client-generator-core: public-utils", () => { it("parameter client projected name", async () => { async function helper(emitterName: string) { - const runner = await createTcgcTestRunnerForEmitter(emitterName); + const runner = await createSdkTestRunner({ emitterName }); const { param } = (await runner.compile(` op func( @test @@ -808,7 +803,7 @@ describe("typespec-client-generator-core: public-utils", () => { }); it("parameter language projected name", async () => { async function helper(emitterName: string, expected: string) { - const runner = await createTcgcTestRunnerForEmitter(emitterName); + const runner = await createSdkTestRunner({ emitterName }); const { param } = (await runner.compile(` op func( @test @@ -830,7 +825,7 @@ describe("typespec-client-generator-core: public-utils", () => { it("parameter json projected name", async () => { async function helper(emitterName: string) { - const runner = await createTcgcTestRunnerForEmitter(emitterName); + const runner = await createSdkTestRunner({ emitterName }); const { param } = (await runner.compile(` op func( @test @@ -848,7 +843,7 @@ describe("typespec-client-generator-core: public-utils", () => { }); it("parameter no projected name", async () => { async function helper(emitterName: string) { - const runner = await createTcgcTestRunnerForEmitter(emitterName); + const runner = await createSdkTestRunner({ emitterName }); const { param } = (await runner.compile(` op func( @test diff --git a/packages/typespec-client-generator-core/test/test-host.ts b/packages/typespec-client-generator-core/test/test-host.ts index 1237ebc9c6..1641d294eb 100644 --- a/packages/typespec-client-generator-core/test/test-host.ts +++ b/packages/typespec-client-generator-core/test/test-host.ts @@ -6,11 +6,12 @@ import { TypeSpecTestLibrary, createTestHost, createTestWrapper, + resolveVirtualPath, } from "@typespec/compiler/testing"; import { HttpTestLibrary } from "@typespec/http/testing"; import { RestTestLibrary } from "@typespec/rest/testing"; import { VersioningTestLibrary } from "@typespec/versioning/testing"; -import { CreateSdkContextOptions, createSdkContext } from "../src/decorators.js"; +import { CreateSdkContextOptions, createSdkContext } from "../src/context.js"; import { SdkContext, SdkEmitterOptions, @@ -19,6 +20,13 @@ import { } from "../src/interfaces.js"; import { SdkTestLibrary } from "../src/testing/index.js"; +export interface CreateSdkTestRunnerOptions extends SdkEmitterOptions { + emitterName?: string; + librariesToAdd?: TypeSpecTestLibrary[]; + autoUsings?: string[]; + packageName?: string; +} + export async function createSdkTestHost(options: CreateSdkTestRunnerOptions = {}) { let libraries = [SdkTestLibrary, HttpTestLibrary, RestTestLibrary, VersioningTestLibrary]; if (options.librariesToAdd) { @@ -29,48 +37,6 @@ export async function createSdkTestHost(options: CreateSdkTestRunnerOptions = {} }); } -export interface SdkTestRunner extends BasicTestRunner { - host: TestHost; - context: SdkContext; - compileWithBuiltInService(code: string): Promise>; - compileWithBuiltInAzureCoreService(code: string): Promise>; - compileWithBuiltInAzureResourceManagerService(code: string): Promise>; - compileWithCustomization(mainCode: string, clientCode: string): Promise>; - compileWithVersionedService(code: string): Promise>; - compileAndDiagnoseWithCustomization( - mainCode: string, - clientCode: string, - ): Promise<[Record, readonly Diagnostic[]]>; -} - -export async function createSdkContextTestHelper< - TOptions extends Record = CreateSdkTestRunnerOptions, - TServiceOperation extends SdkServiceOperation = SdkHttpOperation, ->( - program: Program, - options: TOptions, - sdkContextOption?: CreateSdkContextOptions, -): Promise> { - const emitContext: EmitContext = { - program: program, - emitterOutputDir: "dummy", - options: options, - getAssetEmitter: null as any, - }; - return await createSdkContext( - emitContext, - options.emitterName ?? "@azure-tools/typespec-csharp", - sdkContextOption, - ); -} - -export interface CreateSdkTestRunnerOptions extends SdkEmitterOptions { - emitterName?: string; - librariesToAdd?: TypeSpecTestLibrary[]; - autoUsings?: string[]; - packageName?: string; -} - export async function createSdkTestRunner( options: CreateSdkTestRunnerOptions = {}, sdkContextOption?: CreateSdkContextOptions, @@ -91,9 +57,12 @@ export async function createSdkTestRunner( sdkTestRunner.host = host; - // compile const baseCompile = sdkTestRunner.compile; - sdkTestRunner.compile = async function compile(code, compileOptions?) { + const baseDiagnose = sdkTestRunner.diagnose; + const baseCompileAndDiagnose = sdkTestRunner.compileAndDiagnose; + + // compile + sdkTestRunner.compile = async (code, compileOptions?) => { const result = await baseCompile(code, compileOptions); sdkTestRunner.context = await createSdkContextTestHelper( sdkTestRunner.program, @@ -104,8 +73,7 @@ export async function createSdkTestRunner( }; // diagnose - const baseDiagnose = sdkTestRunner.diagnose; - sdkTestRunner.diagnose = async function diagnose(code, compileOptions?) { + sdkTestRunner.diagnose = async (code, compileOptions?) => { const result = await baseDiagnose(code, compileOptions); sdkTestRunner.context = await createSdkContextTestHelper( sdkTestRunner.program, @@ -116,8 +84,7 @@ export async function createSdkTestRunner( }; // compile and diagnose - const baseCompileAndDiagnose = sdkTestRunner.compileAndDiagnose; - sdkTestRunner.compileAndDiagnose = async function compileAndDiagnose(code, compileOptions?) { + sdkTestRunner.compileAndDiagnose = async (code, compileOptions?) => { const result = await baseCompileAndDiagnose(code, compileOptions); sdkTestRunner.context = await createSdkContextTestHelper( sdkTestRunner.program, @@ -128,7 +95,7 @@ export async function createSdkTestRunner( }; // compile with dummy service definition - sdkTestRunner.compileWithBuiltInService = async function compileWithBuiltInService(code) { + sdkTestRunner.compileWithBuiltInService = async (code) => { const result = await baseCompile( `@service({title: "Test Service"}) namespace TestService; ${code}`, @@ -145,32 +112,30 @@ export async function createSdkTestRunner( }; // compile with dummy service definition - sdkTestRunner.compileWithBuiltInAzureCoreService = - async function compileWithBuiltInAzureCoreService(code) { - const result = await baseCompile( - ` + sdkTestRunner.compileWithBuiltInAzureCoreService = async (code) => { + const result = await baseCompile( + ` @useDependency(Versions.v1_0_Preview_2) @server("http://localhost:3000", "endpoint") @service() namespace My.Service; ${code}`, - { - noEmit: true, - }, - ); - sdkTestRunner.context = await createSdkContextTestHelper( - sdkTestRunner.program, - options, - sdkContextOption, - ); - return result; - }; + { + noEmit: true, + }, + ); + sdkTestRunner.context = await createSdkContextTestHelper( + sdkTestRunner.program, + options, + sdkContextOption, + ); + return result; + }; // compile with dummy arm service definition - sdkTestRunner.compileWithBuiltInAzureResourceManagerService = - async function compileWithBuiltInAzureResourceManagerService(code) { - const result = await baseCompile( - ` + sdkTestRunner.compileWithBuiltInAzureResourceManagerService = async (code) => { + const result = await baseCompile( + ` @armProviderNamespace("My.Service") @server("http://localhost:3000", "endpoint") @service({title: "My.Service"}) @@ -185,40 +150,10 @@ export async function createSdkTestRunner( V2024_04_01_PREVIEW: "2024-04-01-preview", } ${code}`, - { - noEmit: true, - }, - ); - sdkTestRunner.context = await createSdkContextTestHelper( - sdkTestRunner.program, - options, - sdkContextOption, - ); - return result; - }; - - const mainAutoCode = [ - ...host.libraries - .filter((x) => x !== StandardTestLibrary) - .map((x) => x.name) - .map((x) => `import "${x}";`), - ...(autoUsings ?? []).map((x) => `using ${x};`), - ].join("\n"); - - const clientAutoCode = [ - ...host.libraries - .filter((x) => x !== StandardTestLibrary) - .map((x) => x.name) - .map((x) => `import "${x}";`), - `import "./main.tsp";`, - ...(autoUsings ?? []).map((x) => `using ${x};`), - ].join("\n"); - - // compile with client.tsp - sdkTestRunner.compileWithCustomization = async function (mainCode, clientCode) { - host.addTypeSpecFile("./main.tsp", `${mainAutoCode}${mainCode}`); - host.addTypeSpecFile("./client.tsp", `${clientAutoCode}${clientCode}`); - const result = await host.compile("./client.tsp"); + { + noEmit: true, + }, + ); sdkTestRunner.context = await createSdkContextTestHelper( sdkTestRunner.program, options, @@ -228,7 +163,7 @@ export async function createSdkTestRunner( }; // compile with versioned service - sdkTestRunner.compileWithVersionedService = async function (code) { + sdkTestRunner.compileWithVersionedService = async (code) => { const result = await baseCompile( ` @service @@ -260,8 +195,38 @@ export async function createSdkTestRunner( return result; }; + const mainAutoCode = [ + ...host.libraries + .filter((x) => x !== StandardTestLibrary) + .map((x) => x.name) + .map((x) => `import "${x}";`), + ...(autoUsings ?? []).map((x) => `using ${x};`), + ].join("\n"); + + const clientAutoCode = [ + ...host.libraries + .filter((x) => x !== StandardTestLibrary) + .map((x) => x.name) + .map((x) => `import "${x}";`), + `import "./main.tsp";`, + ...(autoUsings ?? []).map((x) => `using ${x};`), + ].join("\n"); + + // compile with client.tsp + sdkTestRunner.compileWithCustomization = async (mainCode, clientCode) => { + host.addTypeSpecFile("./main.tsp", `${mainAutoCode}${mainCode}`); + host.addTypeSpecFile("./client.tsp", `${clientAutoCode}${clientCode}`); + const result = await host.compile("./client.tsp"); + sdkTestRunner.context = await createSdkContextTestHelper( + sdkTestRunner.program, + options, + sdkContextOption, + ); + return result; + }; + // compile and diagnose with client.tsp - sdkTestRunner.compileAndDiagnoseWithCustomization = async function (mainCode, clientCode) { + sdkTestRunner.compileAndDiagnoseWithCustomization = async (mainCode, clientCode) => { host.addTypeSpecFile("./main.tsp", `${mainAutoCode}${mainCode}`); host.addTypeSpecFile("./client.tsp", `${clientAutoCode}${clientCode}`); const result = await host.compileAndDiagnose("./client.tsp"); @@ -276,14 +241,39 @@ export async function createSdkTestRunner( return sdkTestRunner; } -export async function createTcgcTestRunnerForEmitter(emitterName: string): Promise { - const runner = await createSdkTestRunner({ emitterName }); - return runner; +export interface SdkTestRunner extends BasicTestRunner { + host: TestHost; + context: SdkContext; + compileWithBuiltInService(code: string): Promise>; + compileWithBuiltInAzureCoreService(code: string): Promise>; + compileWithBuiltInAzureResourceManagerService(code: string): Promise>; + compileWithVersionedService(code: string): Promise>; + compileWithCustomization(mainCode: string, clientCode: string): Promise>; + compileAndDiagnoseWithCustomization( + mainCode: string, + clientCode: string, + ): Promise<[Record, readonly Diagnostic[]]>; } -export function removeRawFromType(type: TType): TType { - const { __raw, ...rest } = type as any; - return rest; +export async function createSdkContextTestHelper< + TOptions extends Record = CreateSdkTestRunnerOptions, + TServiceOperation extends SdkServiceOperation = SdkHttpOperation, +>( + program: Program, + options: TOptions, + sdkContextOption?: CreateSdkContextOptions, +): Promise> { + const emitContext: EmitContext = { + program: program, + emitterOutputDir: resolveVirtualPath("tsp-output"), + options: options, + getAssetEmitter: null as any, + }; + return await createSdkContext( + emitContext, + options.emitterName ?? "@azure-tools/typespec-csharp", + sdkContextOption, + ); } export function hasFlag(value: T, flag: T): boolean { diff --git a/packages/typespec-client-generator-core/test/types/enum-types.test.ts b/packages/typespec-client-generator-core/test/types/enum-types.test.ts index 8ea09108e9..ac887ce533 100644 --- a/packages/typespec-client-generator-core/test/types/enum-types.test.ts +++ b/packages/typespec-client-generator-core/test/types/enum-types.test.ts @@ -4,11 +4,7 @@ import { deepEqual, deepStrictEqual, ok, strictEqual } from "assert"; import { afterEach, beforeEach, describe, it } from "vitest"; import { SdkEnumType, SdkModelType, SdkUnionType, UsageFlags } from "../../src/interfaces.js"; import { getClientType, getSdkEnum } from "../../src/types.js"; -import { - SdkTestRunner, - createSdkTestRunner, - createTcgcTestRunnerForEmitter, -} from "../test-host.js"; +import { SdkTestRunner, createSdkTestRunner } from "../test-host.js"; describe("typespec-client-generator-core: enum types", () => { let runner: SdkTestRunner; @@ -359,7 +355,7 @@ describe("typespec-client-generator-core: enum types", () => { `); async function helper(emitterName: string, enumName: string, enumValueName: string) { - const runner = await createTcgcTestRunnerForEmitter(emitterName); + const runner = await createSdkTestRunner({ emitterName }); const { Enum1 } = (await runner.compile(` @service({}) namespace MyService { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d6e69d4ae0..eaef5b5135 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2690,6 +2690,9 @@ importers: pluralize: specifier: ^8.0.0 version: 8.0.0 + yaml: + specifier: ~2.5.1 + version: 2.5.1 devDependencies: '@azure-tools/typespec-azure-core': specifier: workspace:~ diff --git a/website/src/content/docs/docs/libraries/typespec-client-generator-core/reference/emitter.md b/website/src/content/docs/docs/libraries/typespec-client-generator-core/reference/emitter.md new file mode 100644 index 0000000000..3b72509c76 --- /dev/null +++ b/website/src/content/docs/docs/libraries/typespec-client-generator-core/reference/emitter.md @@ -0,0 +1,62 @@ +--- +title: "Emitter usage" +--- + +## Usage + +1. Via the command line + +```bash +tsp compile . --emit=@azure-tools/typespec-client-generator-core +``` + +2. Via the config + +```yaml +emit: + - "@azure-tools/typespec-client-generator-core" +``` + +The config can be extended with options as follows: + +```yaml +emit: + - "@azure-tools/typespec-client-generator-core" +options: + "@azure-tools/typespec-client-generator-core": + option: value +``` + +## Emitter options + +### `generate-protocol-methods` + +**Type:** `boolean` + +### `generate-convenience-methods` + +**Type:** `boolean` + +### `package-name` + +**Type:** `string` + +### `flatten-union-as-enum` + +**Type:** `boolean` + +### `api-version` + +**Type:** `string` + +### `examples-directory` + +**Type:** `string` + +### `examples-dir` + +**Type:** `string` + +### `emitter-name` + +**Type:** `string` diff --git a/website/src/content/docs/docs/libraries/typespec-client-generator-core/reference/index.mdx b/website/src/content/docs/docs/libraries/typespec-client-generator-core/reference/index.mdx index 196f5d1a42..7b916a3d3d 100644 --- a/website/src/content/docs/docs/libraries/typespec-client-generator-core/reference/index.mdx +++ b/website/src/content/docs/docs/libraries/typespec-client-generator-core/reference/index.mdx @@ -28,6 +28,10 @@ npm install --save-peer @azure-tools/typespec-client-generator-core +## Emitter usage + +[See documentation](./emitter.md) + ## Azure ## Azure.ClientGenerator