diff --git a/.chronus/changes/add-python-duration-seconds-milliseconds-encode-2026-6-10-9-3-37.md b/.chronus/changes/add-python-duration-seconds-milliseconds-encode-2026-6-10-9-3-37.md new file mode 100644 index 00000000000..55229f548a3 --- /dev/null +++ b/.chronus/changes/add-python-duration-seconds-milliseconds-encode-2026-6-10-9-3-37.md @@ -0,0 +1,7 @@ +--- +changeKind: feature +packages: + - "@typespec/http-client-python" +--- + +Support `datetime.timedelta` for `duration` types encoded as `seconds` or `milliseconds`. SDK users can now pass a `datetime.timedelta` (instead of a raw `int`/`float`) and responses are deserialized back into `datetime.timedelta`. diff --git a/.chronus/changes/add-python-multiple-services-tests-2026-6-10-8-56-11.md b/.chronus/changes/add-python-multiple-services-tests-2026-6-10-8-56-11.md new file mode 100644 index 00000000000..14c091683a4 --- /dev/null +++ b/.chronus/changes/add-python-multiple-services-tests-2026-6-10-8-56-11.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add sync and async mock_api tests for the `service/multiple-services` Spector scenario and enable its regeneration. diff --git a/.chronus/changes/copilot-add-spector-case-serialization-2026-5-1-18-57-48.md b/.chronus/changes/copilot-add-spector-case-serialization-2026-5-1-18-57-48.md new file mode 100644 index 00000000000..6a25bdb8a4a --- /dev/null +++ b/.chronus/changes/copilot-add-spector-case-serialization-2026-5-1-18-57-48.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-specs" +--- + +Add encode/duration lossy Spector scenarios verifying a duration whose value carries more precision than the target integer encoding (fractional seconds and sub-millisecond milliseconds) is serialized as an integer \ No newline at end of file diff --git a/.chronus/changes/fix-openapi3-import-cookie-parameters-2026-6-16.md b/.chronus/changes/fix-openapi3-import-cookie-parameters-2026-6-16.md new file mode 100644 index 00000000000..5aa7c55569f --- /dev/null +++ b/.chronus/changes/fix-openapi3-import-cookie-parameters-2026-6-16.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@typespec/openapi3" +--- + +Fix OpenAPI import to emit `@cookie` decorators for cookie parameters, including nullable and type-null schema variants. diff --git a/.chronus/changes/fix-paging-unset-body-placement-2026-06-10.md b/.chronus/changes/fix-paging-unset-body-placement-2026-06-10.md new file mode 100644 index 00000000000..a86f2075fa3 --- /dev/null +++ b/.chronus/changes/fix-paging-unset-body-placement-2026-06-10.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@typespec/http-client-python" +--- + +Fix `UnboundLocalError` for paging operations with a flattened JSON model body. The request body is now constructed once outside the `prepare_request` callback (and before the body is serialized into the request content) instead of inside the closure, where assigning `body` made it an unbound local on every page fetch. diff --git a/.chronus/changes/fix-sphinx-required-after-code-block-2026-6-9-15-20-0.md b/.chronus/changes/fix-sphinx-required-after-code-block-2026-6-9-15-20-0.md new file mode 100644 index 00000000000..cf2ec9852d7 --- /dev/null +++ b/.chronus/changes/fix-sphinx-required-after-code-block-2026-6-9-15-20-0.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@typespec/http-client-python" +--- + +Fix Sphinx docstring rendering when a `Required.` (or other) annotation followed a code block. The annotation is now inserted into the prose before the code block instead of being appended after it. diff --git a/.chronus/changes/fix-test-case-for-response-error-2026-6-16-0-0-0.md b/.chronus/changes/fix-test-case-for-response-error-2026-6-16-0-0-0.md new file mode 100644 index 00000000000..43c6af75ddf --- /dev/null +++ b/.chronus/changes/fix-test-case-for-response-error-2026-6-16-0-0-0.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Use specific exception types in status code range mock_api tests for sync and async diff --git a/.chronus/changes/http-client-java-add-e2e-tests-2026-6-11-3-30-0.md b/.chronus/changes/http-client-java-add-e2e-tests-2026-6-11-3-30-0.md new file mode 100644 index 00000000000..a9150ca5029 --- /dev/null +++ b/.chronus/changes/http-client-java-add-e2e-tests-2026-6-11-3-30-0.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-java" +--- + +Add e2e tests for parameters/body-root, parameters/query special char, type/model/inheritance/single-discriminator no-subtypes, azure/resourcemanager/common-properties arm-resource-identifiers, and azure/resourcemanager/management-group scenarios diff --git a/.chronus/changes/http-client-java-update-deps-2026-6-10-15-41-00.md b/.chronus/changes/http-client-java-update-deps-2026-6-10-15-41-00.md new file mode 100644 index 00000000000..5d20285f5be --- /dev/null +++ b/.chronus/changes/http-client-java-update-deps-2026-6-10-15-41-00.md @@ -0,0 +1,7 @@ +--- +changeKind: dependencies +packages: + - "@typespec/http-client-java" +--- + +Update Node.js dependencies to latest (compiler 1.13.0, TCGC 0.69.0, azure-core 0.69.0) and bump version to 0.9.0 diff --git a/.chronus/changes/http-specs-fix-dollar-sign-route-2026-6-11-5-41-26.md b/.chronus/changes/http-specs-fix-dollar-sign-route-2026-6-11-5-41-26.md new file mode 100644 index 00000000000..37e155489d3 --- /dev/null +++ b/.chronus/changes/http-specs-fix-dollar-sign-route-2026-6-11-5-41-26.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@typespec/http-specs" +--- + +Fix the dollar-sign query scenario route to match the mock API. diff --git a/.chronus/changes/python-add-arm-managementgroup-armresourceidentifier-tests-2026-6-10-8-52-0.md b/.chronus/changes/python-add-arm-managementgroup-armresourceidentifier-tests-2026-6-10-8-52-0.md new file mode 100644 index 00000000000..d116b0ad28e --- /dev/null +++ b/.chronus/changes/python-add-arm-managementgroup-armresourceidentifier-tests-2026-6-10-8-52-0.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add sync and async mock_api tests for the management group scoped resources and ARM resource identifier Spector scenarios from azure-http-specs. diff --git a/.chronus/changes/python-add-dollar-sign-query-test-2026-6-15-6-6-0.md b/.chronus/changes/python-add-dollar-sign-query-test-2026-6-15-6-6-0.md new file mode 100644 index 00000000000..ef140aa2e84 --- /dev/null +++ b/.chronus/changes/python-add-dollar-sign-query-test-2026-6-15-6-6-0.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add mock API test for the `Parameters_Query_SpecialChar_dollarSign` Spector scenario. diff --git a/.chronus/changes/python-custom-error-status-mapping-2026-6-16-9-52-50.md b/.chronus/changes/python-custom-error-status-mapping-2026-6-16-9-52-50.md new file mode 100644 index 00000000000..882cda4bed2 --- /dev/null +++ b/.chronus/changes/python-custom-error-status-mapping-2026-6-16-9-52-50.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@typespec/http-client-python" +--- + +Raise the dedicated azure-core error type for standard status codes (401, 404, 409, 304) whenever a customized error model covers them (ranged or default error responses), instead of falling back to a generic `HttpResponseError` or raising without the error body. The error body is now deserialized into the customized error model first and attached to the raised error. For example, a `401` covered by a custom error model now raises `ClientAuthenticationError` with the customized error body shape. diff --git a/.chronus/changes/refactor-node-python-emitter-2026-5-3-15-23-59.md b/.chronus/changes/refactor-node-python-emitter-2026-5-3-15-23-59.md new file mode 100644 index 00000000000..1d679fb8619 --- /dev/null +++ b/.chronus/changes/refactor-node-python-emitter-2026-5-3-15-23-59.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Refactor Node usage in Python emitter to make it browser bundleable \ No newline at end of file diff --git a/.github/instructions/http-client-csharp.instructions.md b/.github/instructions/http-client-csharp.instructions.md index 81e9a172f2b..a0eb8751fdc 100644 --- a/.github/instructions/http-client-csharp.instructions.md +++ b/.github/instructions/http-client-csharp.instructions.md @@ -26,3 +26,4 @@ applyTo: "packages/http-client-csharp/**/*" - Regenerate all generated libraries by running `eng/scripts/Generate.ps1`. - Ensure all unit tests are passing. - Do not comment out or delete any existing tests. +- Run the Cop static-analysis checks locally with `npm run cop` (which invokes `eng/scripts/Invoke-Cop.ps1`). This downloads the pinned Agent Cop release and runs the rules under `cop-checks/` against the generator, failing on any violation. Ensure it reports `cop checks passed.` before committing C# changes. diff --git a/cspell.yaml b/cspell.yaml index 58ec6e0489f..d2e086c1875 100644 --- a/cspell.yaml +++ b/cspell.yaml @@ -238,6 +238,7 @@ words: - reinjected - repr - respecify + - responseasbool - rjust - rollup - rpaas @@ -250,6 +251,8 @@ words: - sdkcore - segmentof - serde + - servicea + - serviceb - setuppy - sfixed - shiki @@ -307,6 +310,7 @@ words: - venvtools - VITE - vitest + - vnet - VNEXT - vsix - vsmarketplace diff --git a/packages/http-client-csharp/cop-checks/main.cop b/packages/http-client-csharp/cop-checks/main.cop index c7d8f30075e..6bbd028296f 100644 --- a/packages/http-client-csharp/cop-checks/main.cop +++ b/packages/http-client-csharp/cop-checks/main.cop @@ -15,7 +15,7 @@ import code import csharp -let cb = code.codebase('csharp') +let cb : Codebase = provider('csharp') # Rule: braces.cop command CHECK-BRACES = foreach cb.Lines:missingBraces => '{error:@red} {item.File.Path}:{item.Number}: missing braces -> {item.Text}' diff --git a/packages/http-client-csharp/docs/emitter.md b/packages/http-client-csharp/docs/emitter.md index f20d6edee33..827da57427a 100644 --- a/packages/http-client-csharp/docs/emitter.md +++ b/packages/http-client-csharp/docs/emitter.md @@ -96,6 +96,12 @@ Set the log level for which to collect traces. The default value is `info`. Set to `true` to disable XML documentation generation. The default value is `false`. +### `disable-roslyn-reduce` + +**Type:** `boolean` + +Set to `true` to skip the Roslyn reduce (simplification) post-processing step. This speeds up generation and is useful when iterating quickly. The default value is `false`. + ### `generator-name` **Type:** `string` @@ -112,7 +118,18 @@ Allows emitter authors to specify the path to a custom emitter package, allowing **Type:** `array` -Paths to generator plugin assemblies (DLLs) or directories containing plugin assemblies. Each plugin must contain a class that extends GeneratorPlugin. +Paths to generator plugin assemblies (DLLs) or directories containing plugin assemblies. Each plugin must contain a class that extends `GeneratorPlugin`. Paths may be absolute or relative to the resolved `emitter-output-dir`. For example, to load plugins that live in a `codegen` folder under the output directory: + +```yaml +options: + "@typespec/http-client-csharp": + plugins: + - "codegen/MyPlugin.dll" # file relative to emitter-output-dir + - "codegen" # directory containing plugin assemblies + - "/abs/path/to/MyPlugin.dll" # absolute path used as-is +``` + +See [Generator plugins](./plugins.md) for a walkthrough on authoring and using plugins. ### `license` diff --git a/packages/http-client-csharp/docs/index.mdx b/packages/http-client-csharp/docs/index.mdx index ca373e97796..d2cbde176f7 100644 --- a/packages/http-client-csharp/docs/index.mdx +++ b/packages/http-client-csharp/docs/index.mdx @@ -32,6 +32,10 @@ npm install --save-peer @typespec/http-client-csharp [See documentation](./emitter.md) +## Generator plugins + +[See documentation](./plugins.md) + ## TypeSpec.HttpClient ## TypeSpec.HttpClient.CSharp diff --git a/packages/http-client-csharp/docs/plugins.md b/packages/http-client-csharp/docs/plugins.md new file mode 100644 index 00000000000..66834b76ef9 --- /dev/null +++ b/packages/http-client-csharp/docs/plugins.md @@ -0,0 +1,101 @@ +--- +title: "Generator plugins" +--- + +## Generator plugins + +Plugins are a lightweight way to customize the C# generator without authoring a full custom generator. A plugin can register additional visitors, rewriters, metadata references, or shared source directories that participate in the normal generation pipeline. This is useful when you want to tweak the generated output (for example, rename types, add attributes, or post-process models) while still using the built-in `ScmCodeModelGenerator`. + +The generator discovers plugins in two ways: + +1. **Automatically**, from the `dist` folder of any package listed in your project's `node_modules`. +2. **Explicitly**, from the paths supplied via the [`plugins`](./emitter.md#plugins) emitter option. + +This document focuses on the `plugins` option, which lets emitter authors point the generator at one or more plugin assemblies (or directories/projects containing them). + +## Authoring a plugin + +A plugin is a C# class that extends `GeneratorPlugin` and overrides `Apply`. The base class is exported via [MEF](https://learn.microsoft.com/dotnet/framework/mef/) using `[InheritedExport]`, so any subclass is discovered automatically once its assembly is loaded — you do not need to add an `[Export]` attribute yourself. + +```csharp +using Microsoft.TypeSpec.Generator; + +public class MyPlugin : GeneratorPlugin +{ + public override void Apply(CodeModelGenerator generator) + { + // Register a custom visitor that transforms the output library. + generator.AddVisitor(new MyLibraryVisitor()); + } +} +``` + +The `CodeModelGenerator` passed to `Apply` exposes the extension points a plugin can use, including: + +- `AddVisitor(LibraryVisitor visitor)` — add a visitor that traverses and modifies the output library. +- `AddRewriter(LibraryRewriter rewriter)` — add a rewriter to transform generated members. +- `AddMetadataReference(MetadataReference reference)` — make additional assemblies available to the generated code. +- `AddSharedSourceDirectory(string sharedSourceDirectory)` — include a directory of shared source files. + +A visitor lets you hook into specific parts of the output. For example, to transform every model: + +```csharp +using Microsoft.TypeSpec.Generator; +using Microsoft.TypeSpec.Generator.Providers; + +public class MyLibraryVisitor : LibraryVisitor +{ + protected override TypeProvider? VisitType(TypeProvider type) + { + // Inspect or modify the generated type here. + return base.VisitType(type); + } +} +``` + +### Plugin project file + +Build your plugin as a class library that references the generator's published NuGet package. Referencing `Microsoft.TypeSpec.Generator.ClientModel` transitively brings in `Microsoft.TypeSpec.Generator`, which contains the `GeneratorPlugin` base class. Use the package version that matches the version of `@typespec/http-client-csharp` you are generating with. A minimal `.csproj` looks like this: + +```xml + + + + net10.0 + enable + + + + + + + +``` + +## Using the `plugins` option + +Once you have a plugin, point the emitter at it using the `plugins` option in `tspconfig.yaml`. Each entry is a path that may be **absolute** or **relative to the resolved `emitter-output-dir`**. A path can point to either: + +- a **file** — a pre-built plugin assembly (`*.dll`), or +- a **directory** containing pre-built plugin assemblies (`*.dll`) or a `.csproj` — when a `.csproj` is present the generator builds it (`dotnet build -c Release`) before loading the resulting assembly. + +For example, to load plugins that live in a `codegen` folder under the output directory: + +```yaml +emit: + - "@typespec/http-client-csharp" +options: + "@typespec/http-client-csharp": + plugins: + - "codegen/MyPlugin.dll" # file relative to emitter-output-dir + - "codegen" # directory containing plugin assemblies + - "/abs/path/to/MyPlugin.dll" # absolute path used as-is +``` + +Notes: + +- Absolute paths are used as-is; relative paths are anchored to the resolved `emitter-output-dir`. +- When a directory contains a `.csproj`, it is built automatically; otherwise the directory is scanned for pre-built `*.dll` files. +- Plugins loaded via the `plugins` option are applied in addition to any plugins discovered through `node_modules`. + +After the assemblies are loaded, every discovered `GeneratorPlugin` has its `Apply` method invoked on the selected generator before generation runs, so all of your registered visitors, rewriters, and references take effect. diff --git a/packages/http-client-csharp/emitter/src/emitter.ts b/packages/http-client-csharp/emitter/src/emitter.ts index 1aaa9c698f2..9df2a95330b 100644 --- a/packages/http-client-csharp/emitter/src/emitter.ts +++ b/packages/http-client-csharp/emitter/src/emitter.ts @@ -150,6 +150,8 @@ export function createConfiguration( "unreferenced-types-handling": options["unreferenced-types-handling"], "disable-xml-docs": options["disable-xml-docs"] === false ? undefined : options["disable-xml-docs"], + "disable-roslyn-reduce": + options["disable-roslyn-reduce"] === false ? undefined : options["disable-roslyn-reduce"], license: sdkContext.sdkPackage.licenseInfo, }; } diff --git a/packages/http-client-csharp/emitter/src/lib/lib.ts b/packages/http-client-csharp/emitter/src/lib/lib.ts index c93ac07963d..a3c5c96a649 100644 --- a/packages/http-client-csharp/emitter/src/lib/lib.ts +++ b/packages/http-client-csharp/emitter/src/lib/lib.ts @@ -95,6 +95,12 @@ const diags: { [code: string]: DiagnosticDefinition } = { default: paramMessage`Convenience method is not supported for PATCH method, it will be turned off. Please set the '@convenientAPI' to false for operation ${"methodCrossLanguageDefinitionId"}.`, }, }, + "unsupported-multipart-convenience-method": { + severity: "warning", + messages: { + default: paramMessage`Convenience method is not supported for multipart content types other than 'multipart/form-data', it will be turned off. Please set the '@convenientAPI' to false for operation ${"methodCrossLanguageDefinitionId"}.`, + }, + }, "unsupported-service-method": { severity: "warning", messages: { diff --git a/packages/http-client-csharp/emitter/src/lib/operation-converter.ts b/packages/http-client-csharp/emitter/src/lib/operation-converter.ts index 72ef7d9f109..59f35f75e03 100644 --- a/packages/http-client-csharp/emitter/src/lib/operation-converter.ts +++ b/packages/http-client-csharp/emitter/src/lib/operation-converter.ts @@ -196,6 +196,20 @@ export function fromSdkServiceMethodOperation( generateConvenience = false; } + const requestMediaTypes = getRequestMediaTypes(method.operation); + if (generateConvenience && isUnsupportedMultipart(requestMediaTypes)) { + diagnostics.add( + createDiagnostic({ + code: "unsupported-multipart-convenience-method", + format: { + methodCrossLanguageDefinitionId: method.crossLanguageDefinitionId, + }, + target: method.__raw ?? NoTarget, + }), + ); + generateConvenience = false; + } + operation = { name: method.name, isExactName: method.isExactName, @@ -217,7 +231,7 @@ export function fromSdkServiceMethodOperation( uri: uri, path: method.operation.path, externalDocsUrl: getExternalDocs(sdkContext, method.operation.__raw.operation)?.url, - requestMediaTypes: getRequestMediaTypes(method.operation), + requestMediaTypes: requestMediaTypes, bufferResponse: true, generateProtocolMethod: shouldGenerateProtocol(sdkContext, method.operation.__raw.operation), generateConvenienceMethod: generateConvenience, @@ -751,6 +765,15 @@ function toStatusCodesArray(range: number | HttpStatusCodeRange): number[] { return statusCodes; } +function isUnsupportedMultipart(requestMediaTypes: string[] | undefined): boolean { + return ( + requestMediaTypes?.some((mediaType) => { + const normalized = mediaType.toLowerCase(); + return normalized.startsWith("multipart/") && normalized !== "multipart/form-data"; + }) ?? false + ); +} + function getRequestMediaTypes(op: SdkHttpOperation): string[] | undefined { const contentTypes = op.parameters.filter( (p) => p.kind === "header" && p.serializedName.toLocaleLowerCase() === "content-type", diff --git a/packages/http-client-csharp/emitter/src/options.ts b/packages/http-client-csharp/emitter/src/options.ts index b980b4121f8..952a756cf04 100644 --- a/packages/http-client-csharp/emitter/src/options.ts +++ b/packages/http-client-csharp/emitter/src/options.ts @@ -16,6 +16,7 @@ export interface CSharpEmitterOptions { debug?: boolean; logLevel?: LoggerLevel; "disable-xml-docs"?: boolean; + "disable-roslyn-reduce"?: boolean; "generator-name"?: string; "emitter-extension-path"?: string; plugins?: string[]; @@ -102,6 +103,13 @@ export const CSharpEmitterOptionsSchema: JSONSchemaType = description: "Set to `true` to disable XML documentation generation. The default value is `false`.", }, + "disable-roslyn-reduce": { + type: "boolean", + nullable: true, + description: + "Set to `true` to skip the Roslyn reduce (simplification) post-processing step. " + + "This speeds up generation and is useful when iterating quickly. The default value is `false`.", + }, "generator-name": { type: "string", nullable: true, @@ -120,7 +128,17 @@ export const CSharpEmitterOptionsSchema: JSONSchemaType = nullable: true, description: "Paths to generator plugin assemblies (DLLs) or directories containing plugin assemblies. " + - "Each plugin must contain a class that extends GeneratorPlugin.", + "Each plugin must contain a class that extends `GeneratorPlugin`. " + + "Paths may be absolute or relative to the resolved `emitter-output-dir`. " + + "For example, to load plugins that live in a `codegen` folder under the output directory:\n\n" + + "```yaml\n" + + "options:\n" + + ' "@typespec/http-client-csharp":\n' + + " plugins:\n" + + ' - "codegen/MyPlugin.dll" # file relative to emitter-output-dir\n' + + ' - "codegen" # directory containing plugin assemblies\n' + + ' - "/abs/path/to/MyPlugin.dll" # absolute path used as-is\n' + + "```", }, license: { type: "object", diff --git a/packages/http-client-csharp/emitter/src/type/configuration.ts b/packages/http-client-csharp/emitter/src/type/configuration.ts index 1f7eaa03af7..2a2f3e2f2e8 100644 --- a/packages/http-client-csharp/emitter/src/type/configuration.ts +++ b/packages/http-client-csharp/emitter/src/type/configuration.ts @@ -5,6 +5,7 @@ export interface Configuration { "package-name": string | null; "unreferenced-types-handling"?: "removeOrInternalize" | "internalize" | "keepAll"; "disable-xml-docs"?: boolean; + "disable-roslyn-reduce"?: boolean; license?: { name: string; company?: string; diff --git a/packages/http-client-csharp/emitter/test/Unit/operation-converter.test.ts b/packages/http-client-csharp/emitter/test/Unit/operation-converter.test.ts index 7671caabb97..3863f242393 100644 --- a/packages/http-client-csharp/emitter/test/Unit/operation-converter.test.ts +++ b/packages/http-client-csharp/emitter/test/Unit/operation-converter.test.ts @@ -622,3 +622,79 @@ describe("Test isExactName propagation on operations and parameters", () => { strictEqual(method.operation.isExactName, true); }); }); + +describe("Multipart convenience method generation", () => { + let runner: TestHost; + + beforeEach(async () => { + runner = await createEmitterTestHost(); + }); + + it("disables convenience method for multipart/mixed and reports a diagnostic", async () => { + const program = await typeSpecCompile( + ` + model MultipartRequest { + id: HttpPart; + profileImage: HttpPart; + } + + @post + @route("/upload") + op upload( + @header contentType: "multipart/mixed", + @multipartBody body: MultipartRequest, + ): NoContentResponse; + `, + runner, + { IsTCGCNeeded: true }, + ); + const context = createEmitterContext(program); + const sdkContext = await createCSharpSdkContext(context); + const [root, diagnostics] = createModel(sdkContext); + + const operation = root.clients[0].methods[0].operation; + ok(operation); + ok(operation.requestMediaTypes?.includes("multipart/mixed")); + // Protocol methods are still generated, but convenience methods are turned off. + strictEqual(operation.generateProtocolMethod, true); + strictEqual(operation.generateConvenienceMethod, false); + + const diagnostic = diagnostics.find( + (d) => d.code === "@typespec/http-client-csharp/unsupported-multipart-convenience-method", + ); + ok(diagnostic); + strictEqual(diagnostic.severity, "warning"); + }); + + it("keeps convenience method for multipart/form-data without a diagnostic", async () => { + const program = await typeSpecCompile( + ` + model MultipartRequest { + profileImage: HttpPart; + } + + @post + @route("/upload") + op upload( + @header contentType: "multipart/form-data", + @multipartBody body: MultipartRequest, + ): NoContentResponse; + `, + runner, + { IsTCGCNeeded: true }, + ); + const context = createEmitterContext(program); + const sdkContext = await createCSharpSdkContext(context); + const [root, diagnostics] = createModel(sdkContext); + + const operation = root.clients[0].methods[0].operation; + ok(operation); + ok(operation.requestMediaTypes?.includes("multipart/form-data")); + strictEqual(operation.generateConvenienceMethod, true); + + const diagnostic = diagnostics.find( + (d) => d.code === "@typespec/http-client-csharp/unsupported-multipart-convenience-method", + ); + strictEqual(diagnostic, undefined); + }); +}); diff --git a/packages/http-client-csharp/emitter/test/Unit/options.test.ts b/packages/http-client-csharp/emitter/test/Unit/options.test.ts index 2d82da0c25d..c5abbecc77b 100644 --- a/packages/http-client-csharp/emitter/test/Unit/options.test.ts +++ b/packages/http-client-csharp/emitter/test/Unit/options.test.ts @@ -125,6 +125,7 @@ describe("Configuration tests", async () => { "package-name": "custom-package", "unreferenced-types-handling": "removeOrInternalize", "disable-xml-docs": true, + "disable-roslyn-reduce": true, license: { name: "Custom License", company: "Custom Company", @@ -141,6 +142,7 @@ describe("Configuration tests", async () => { expect(config["package-name"]).toBe("custom-package"); expect(config["unreferenced-types-handling"]).toBe("removeOrInternalize"); expect(config["disable-xml-docs"]).toBe(true); + expect(config["disable-roslyn-reduce"]).toBe(true); expect(config.license).toEqual({ name: "Custom License", company: "Custom Company", diff --git a/packages/http-client-csharp/eng/scripts/Invoke-Cop.ps1 b/packages/http-client-csharp/eng/scripts/Invoke-Cop.ps1 index ae33b0fba0e..f8f8f880acb 100644 --- a/packages/http-client-csharp/eng/scripts/Invoke-Cop.ps1 +++ b/packages/http-client-csharp/eng/scripts/Invoke-Cop.ps1 @@ -16,20 +16,29 @@ the rule files. This keeps cop targeted at the generator (via -t) and avoids scanning node_modules or the rest of the repository. .PARAMETER Version -The cop release tag to use, or "latest" (default) to track the newest release. - -NOTE: cop auto-restores its provider packages (code, csharp) from the GitHub -feed, and the feed always serves the *latest* provider build. Those providers -are version-locked to the cop runtime assembly, so the binary must match the -provider version the feed currently serves -- otherwise the provider fails to -load ("Could not load file or assembly 'cop, Version=...'"). Because the feed -moves with upstream, we default to "latest" so the binary stays in lockstep with -the providers. Pass an explicit tag only to reproduce a historical run. +The cop release tag to use. Defaults to a pinned tag so CI is reproducible and +upstream cop releases cannot break our build. + +NOTE: cop's provider packages (code, csharp) are version-locked to the cop +runtime assembly -- a mismatch makes the provider fail to load ("Could not load +file or assembly 'cop, Version=...'"). We do NOT rely on cop's auto-restore feed +(which always serves the *latest* provider build); instead we vendor the +provider packages from the cop repo at the tag reported by `cop -v` (see below), +so they always match the downloaded binary. Because of that, pinning the binary +to a fixed tag is safe: the providers are pinned to the same tag automatically. + +Bumping the pinned version is a deliberate, reviewable change. Before bumping, +verify the rule files in cop-checks/ still run against the new release, since +cop occasionally makes breaking changes to its query API between releases. +Pass "latest" to test against the newest release. #> [CmdletBinding()] param( - [string] $Version = "latest" + # Pinned cop release. Bump deliberately after verifying the cop-checks/ rules + # still run against the new release (cop can make breaking API changes + # between releases). Pass "latest" to test against the newest release. + [string] $Version = "v2026.6.10.1" ) $ErrorActionPreference = 'Stop' @@ -71,9 +80,9 @@ else { $url = "https://github.com/KrzysztofCwalina/cop/releases/download/$Version/$asset" } -# Cache the downloaded tool per version + platform. When tracking "latest" the -# tag is not fixed, so always re-download to stay in lockstep with the feed's -# provider packages. +# Cache the downloaded tool per version + platform. A pinned tag is immutable, so +# a cached copy can be reused; when "latest" is requested the tag is not fixed, so +# always re-download to stay in lockstep with the feed's provider packages. $toolDir = Join-Path ([System.IO.Path]::GetTempPath()) "cop-$Version-$os-$arch" $copPath = Join-Path $toolDir $exe diff --git a/packages/http-client-csharp/eng/scripts/RegenPreview.psm1 b/packages/http-client-csharp/eng/scripts/RegenPreview.psm1 index 4f08d46666f..03d43effaae 100644 --- a/packages/http-client-csharp/eng/scripts/RegenPreview.psm1 +++ b/packages/http-client-csharp/eng/scripts/RegenPreview.psm1 @@ -175,13 +175,14 @@ function Update-MgmtGenerator { .DESCRIPTION This function handles the management plane generator setup: - 1. Updates package.json with local unbranded and Azure generator dependencies + 1. Redirects the mgmt generator's "dependencies" for both @azure-typespec/http-client-csharp + and @typespec/http-client-csharp to the locally built packages 2. Runs npm install 3. Runs npm run clean to ensure a clean build 4. Builds the management plane generator 5. Packages the management plane generator 6. Updates eng folder emitter package artifacts (azure-typespec-http-client-csharp-mgmt-emitter-package.json) - 7. Updates mgmt emitter package artifact's devDependency for @typespec/http-client-csharp + and regenerates the lock file with the full local dependency graph (mgmt + Azure + unbranded) This function is designed to be called from RegenPreview.ps1 and uses the same versioning scheme as the main generators. It derives all necessary paths from the @@ -232,32 +233,31 @@ function Update-MgmtGenerator { Write-Host "Local version: $LocalVersion" -ForegroundColor Gray Write-Host "" - # Use shared helper to build and package the mgmt generator + # Use shared helper to build and package the mgmt generator. + # The mgmt generator declares BOTH the Azure and unbranded generators under + # "dependencies" (not devDependencies), so both must be redirected to the locally + # built packages before packing. Otherwise the packed mgmt emitter would still + # reference the published Azure/unbranded versions instead of the local builds. $mgmtPackagePath = Update-GeneratorPackage ` -GeneratorPath $mgmtGeneratorPath ` - -Dependencies @{ '@azure-typespec/http-client-csharp' = $azurePackagePath } ` - -DevDependencies @{ '@typespec/http-client-csharp' = $unbrandedPackagePath } ` + -Dependencies @{ + '@azure-typespec/http-client-csharp' = $azurePackagePath + '@typespec/http-client-csharp' = $unbrandedPackagePath + } ` -LocalVersion $LocalVersion ` -DebugFolder $DebugFolder ` -UseNpmCi $false - # Update eng folder mgmt emitter package artifacts + # Update eng folder mgmt emitter package artifacts. + # The emitter package only declares @azure-typespec/http-client-csharp-mgmt directly; + # the Azure + unbranded packages are pulled in transitively from the mgmt tgz, which + # now points at the local file: packages. Installing the local mgmt tgz regenerates + # the lock file with the full local dependency graph. Write-Host "Updating mgmt emitter package artifacts..." -ForegroundColor Gray - # First, update the mgmt emitter package artifact's devDependency for @typespec/http-client-csharp $mgmtEmitterJson = Join-Path $EngFolder "azure-typespec-http-client-csharp-mgmt-emitter-package.json" - $mgmtEmitterPackageJson = Get-Content $mgmtEmitterJson -Raw | ConvertFrom-Json - # Check if devDependencies exists and has @typespec/http-client-csharp - if ($mgmtEmitterPackageJson.devDependencies -and - $mgmtEmitterPackageJson.devDependencies.PSObject.Properties['@typespec/http-client-csharp']) { - # Use file path to the unbranded package, not just the version string - $mgmtEmitterPackageJson.devDependencies.'@typespec/http-client-csharp' = "file:$unbrandedPackagePath" - $mgmtEmitterPackageJson | ConvertTo-Json -Depth 100 | Set-Content $mgmtEmitterJson -Encoding UTF8 - Write-Host " Updated @typespec/http-client-csharp devDependency to file:$unbrandedPackagePath" -ForegroundColor Green - } - - # Now update the package-lock.json with both dependencies + # Regenerate the package-lock.json with the full (local) dependency graph $tempDir = Join-Path $EngFolder "temp-mgmt-package-update" New-Item -ItemType Directory -Path $tempDir -Force | Out-Null diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ModelSerializationExtensionsDefinition.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ModelSerializationExtensionsDefinition.cs index f1c22d729e2..34cfb90210c 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ModelSerializationExtensionsDefinition.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ModelSerializationExtensionsDefinition.cs @@ -211,14 +211,14 @@ protected override SuppressionStatement[] BuildDisabledFileWarnings() : []; private bool HasFileBinaryContentJsonModel - => _hasFileBinaryContentJsonModel ??= HasFileBinaryContentModelForUsage(InputModelTypeUsage.Json); + => _hasFileBinaryContentJsonModel ??= HasFileTypeForUsage(InputModelTypeUsage.Json); private bool? _hasFileBinaryContentJsonModel; private bool HasFileBinaryContentXmlModel - => _hasFileBinaryContentXmlModel ??= HasFileBinaryContentModelForUsage(InputModelTypeUsage.Xml); + => _hasFileBinaryContentXmlModel ??= HasFileTypeForUsage(InputModelTypeUsage.Xml); private bool? _hasFileBinaryContentXmlModel; - private static bool HasFileBinaryContentModelForUsage(InputModelTypeUsage usage) + private static bool HasFileTypeForUsage(InputModelTypeUsage usage) { foreach (var model in ScmCodeModelGenerator.Instance.InputLibrary.InputNamespace.Models) { @@ -229,8 +229,7 @@ private static bool HasFileBinaryContentModelForUsage(InputModelTypeUsage usage) foreach (var property in model.Properties) { - var propertyType = ScmCodeModelGenerator.Instance.TypeFactory.CreateCSharpType(property.Type); - if (propertyType != null && ScmModelProvider.IsFileBinaryContentType(propertyType)) + if (IsFileInputType(property.Type)) { return true; } @@ -240,6 +239,16 @@ private static bool HasFileBinaryContentModelForUsage(InputModelTypeUsage usage) return false; } + private static bool IsFileInputType(InputType type) => type switch + { + InputModelType { IsFileType: true } => true, + InputPrimitiveType { IsFileType: true } => true, + InputArrayType array => IsFileInputType(array.ValueType), + InputDictionaryType dictionary => IsFileInputType(dictionary.ValueType), + InputNullableType nullable => IsFileInputType(nullable.Type), + _ => false, + }; + private MethodProvider BuildWriteFileBinaryContentMethodProvider() { var valueParameter = new ParameterProvider("value", FormattableStringHelpers.Empty, typeof(FileBinaryContent)); diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ScmMethodProviderCollection.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ScmMethodProviderCollection.cs index 1cced6bbb5d..a883d0321e0 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ScmMethodProviderCollection.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ScmMethodProviderCollection.cs @@ -91,13 +91,31 @@ protected virtual IReadOnlyList BuildMethods() if (_generateConvenienceMethod) { - return - [ + var methods = new List + { syncProtocol, asyncProtocol, - BuildConvenienceMethod(syncProtocol, false), - BuildConvenienceMethod(asyncProtocol, true), - ]; + }; + + if (_pagingServiceMethod != null) + { + methods.Add(BuildConvenienceMethod(syncProtocol, false)); + methods.Add(BuildConvenienceMethod(asyncProtocol, true)); + } + else + { + if (ProtocolMethodExists(syncProtocol)) + { + methods.Add(BuildConvenienceMethod(syncProtocol, false)); + } + + if (ProtocolMethodExists(asyncProtocol)) + { + methods.Add(BuildConvenienceMethod(asyncProtocol, true)); + } + } + + return methods; } return @@ -107,6 +125,25 @@ protected virtual IReadOnlyList BuildMethods() ]; } + private bool ProtocolMethodExists(MethodProvider generatedProtocolMethod) + { + if (!generatedProtocolMethod.IsMethodSuppressed()) + { + return true; + } + + foreach (var method in EnclosingType.CustomCodeView?.Methods ?? []) + { + if (!method.IsPartialMethod && + MethodSignatureBase.SignatureComparer.Equals(method.Signature, generatedProtocolMethod.Signature)) + { + return true; + } + } + + return false; + } + private ScmMethodProvider BuildConvenienceMethod(MethodProvider protocolMethod, bool isAsync) { if (EnclosingType is not ClientProvider client) diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/ClientProviderCustomizationTests.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/ClientProviderCustomizationTests.cs index b7c64f4be5e..72ee46c9658 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/ClientProviderCustomizationTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/ClientProviderCustomizationTests.cs @@ -2,9 +2,11 @@ // Licensed under the MIT License. using System.ClientModel; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Microsoft.TypeSpec.Generator; using Microsoft.TypeSpec.Generator.ClientModel.Providers; using Microsoft.TypeSpec.Generator.Input; using Microsoft.TypeSpec.Generator.Primitives; @@ -154,6 +156,171 @@ public async Task CanReplaceOpMethod() } + // Validates that when the protocol method is suppressed via [CodeGenSuppress] without a custom + // replacement, the convenience method (which calls the protocol method) is not generated either, + // since it would not compile. + [Test] + public async Task SuppressedProtocolMethodSkipsConvenienceMethod() + { + var inputOperation = InputFactory.Operation("HelloAgain"); + var inputServiceMethod = InputFactory.BasicServiceMethod("test", inputOperation); + var inputClient = InputFactory.Client("TestClient", methods: [inputServiceMethod]); + var mockGenerator = await MockHelpers.LoadMockGeneratorAsync( + clients: () => [inputClient], + compilation: async () => await Helpers.GetCompilationFromDirectoryAsync()); + + var clientProvider = mockGenerator.Object.OutputLibrary.TypeProviders.SingleOrDefault(t => t is ClientProvider); + Assert.IsNotNull(clientProvider); + + // Both the suppressed protocol methods and the dependent convenience methods should be gone. + var helloAgainMethods = clientProvider!.Methods + .Where(m => m.Signature.Name == "HelloAgain" || m.Signature.Name == "HelloAgainAsync") + .ToList(); + Assert.AreEqual(0, helloAgainMethods.Count); + } + + // Validates that when the protocol method is suppressed via [CodeGenSuppress] but replaced by a + // custom (non-partial) method implementation, the convenience method is still generated because + // it will compile against the custom protocol method. + [Test] + public async Task SuppressedProtocolMethodWithCustomCodeKeepsConvenienceMethod() + { + var inputOperation = InputFactory.Operation("HelloAgain"); + var inputServiceMethod = InputFactory.BasicServiceMethod("test", inputOperation); + var inputClient = InputFactory.Client("TestClient", methods: [inputServiceMethod]); + var mockGenerator = await MockHelpers.LoadMockGeneratorAsync( + clients: () => [inputClient], + compilation: async () => await Helpers.GetCompilationFromDirectoryAsync()); + + var clientProvider = mockGenerator.Object.OutputLibrary.TypeProviders.SingleOrDefault(t => t is ClientProvider); + Assert.IsNotNull(clientProvider); + + // The generated protocol methods are suppressed (provided by custom code), but the convenience + // methods (taking a CancellationToken) should still be generated. + var syncConvenience = clientProvider!.Methods.SingleOrDefault(m => + m.Signature.Name == "HelloAgain" && + m.Signature.Parameters.Any(p => p.Type.Equals(typeof(System.Threading.CancellationToken)))); + var asyncConvenience = clientProvider.Methods.SingleOrDefault(m => + m.Signature.Name == "HelloAgainAsync" && + m.Signature.Parameters.Any(p => p.Type.Equals(typeof(System.Threading.CancellationToken)))); + + Assert.IsNotNull(syncConvenience); + Assert.IsNotNull(asyncConvenience); + + // Validate the generated convenience methods (signature and body) still call into the + // (custom) protocol methods. + string syncActual; + using (var syncWriter = new CodeWriter()) + { + syncWriter.WriteMethod(syncConvenience!); + syncActual = syncWriter.ToString(false); + } + + string asyncActual; + using (var asyncWriter = new CodeWriter()) + { + asyncWriter.WriteMethod(asyncConvenience!); + asyncActual = asyncWriter.ToString(false); + } + + Assert.AreEqual(Helpers.GetExpectedFromFile("Sync"), syncActual); + Assert.AreEqual(Helpers.GetExpectedFromFile("Async"), asyncActual); + + // The generated protocol methods (taking RequestOptions) should be suppressed in favor of the custom ones. + var generatedProtocolMethods = clientProvider.Methods + .Where(m => (m.Signature.Name == "HelloAgain" || m.Signature.Name == "HelloAgainAsync") && + m.Signature.Parameters.Any(p => p.Type.Equals(typeof(RequestOptions)))) + .ToList(); + Assert.AreEqual(0, generatedProtocolMethods.Count); + } + + // Validates that when the protocol method is suppressed via [CodeGenSuppress] and the customization + // only provides an overload with an additional parameter (a different signature), the convenience + // method is still skipped because no replacement with the matching protocol signature exists. + [Test] + public async Task SuppressedProtocolMethodWithCustomOverloadSkipsConvenienceMethod() + { + var inputOperation = InputFactory.Operation("HelloAgain"); + var inputServiceMethod = InputFactory.BasicServiceMethod("test", inputOperation); + var inputClient = InputFactory.Client("TestClient", methods: [inputServiceMethod]); + var mockGenerator = await MockHelpers.LoadMockGeneratorAsync( + clients: () => [inputClient], + compilation: async () => await Helpers.GetCompilationFromDirectoryAsync()); + + var clientProvider = mockGenerator.Object.OutputLibrary.TypeProviders.SingleOrDefault(t => t is ClientProvider); + Assert.IsNotNull(clientProvider); + + // The custom overloads (with an additional parameter) do not match the suppressed protocol + // signature, so both the protocol and the dependent convenience methods should be gone. + var generatedHelloAgainMethods = clientProvider!.Methods + .Where(m => m.Signature.Name == "HelloAgain" || m.Signature.Name == "HelloAgainAsync") + .ToList(); + Assert.AreEqual(0, generatedHelloAgainMethods.Count); + + // The additional custom overload is still present in the custom code view. + var customMethods = clientProvider.CustomCodeView?.Methods ?? []; + Assert.AreEqual(2, customMethods.Count); + Assert.IsTrue(customMethods.All(m => m.Signature.Parameters.Count == 2)); + } + + // Validates that when a paging protocol method is suppressed via [CodeGenSuppress], the paging + // helpers (collection result definitions) are still generated so that custom code can reference + // them. Unlike non-paging convenience methods, paging convenience methods instantiate the + // collection result directly instead of calling the protocol method, so they are always generated. + [Test] + public async Task SuppressedPagingProtocolMethodKeepsPagingHelpers() + { + var inputModel = InputFactory.Model("item", properties: + [ + InputFactory.Property("color", InputPrimitiveType.String, isRequired: true), + ]); + var pagingMetadata = InputFactory.NextLinkPagingMetadata(["items"], ["nextLink"], InputResponseLocation.Body); + var response = InputFactory.OperationResponse( + [200], + InputFactory.Model( + "page", + properties: + [ + InputFactory.Property("items", InputFactory.Array(inputModel)), + InputFactory.Property("nextLink", InputPrimitiveType.Url), + ])); + var inputOperation = InputFactory.Operation("GetItems", responses: [response]); + var inputServiceMethod = InputFactory.PagingServiceMethod("GetItems", inputOperation, pagingMetadata: pagingMetadata); + var inputClient = InputFactory.Client("TestClient", methods: [inputServiceMethod]); + var mockGenerator = await MockHelpers.LoadMockGeneratorAsync( + inputModels: () => [inputModel], + clients: () => [inputClient], + compilation: async () => await Helpers.GetCompilationFromDirectoryAsync()); + + var clientProvider = (ClientProvider)mockGenerator.Object.OutputLibrary.TypeProviders.Single(t => t is ClientProvider); + + // The generated protocol methods (taking RequestOptions) are suppressed. + var generatedProtocolMethods = clientProvider.Methods + .Where(m => (m.Signature.Name == "GetItems" || m.Signature.Name == "GetItemsAsync") && + m.Signature.Parameters.Any(p => p.Type.Equals(typeof(RequestOptions)))) + .ToList(); + Assert.AreEqual(0, generatedProtocolMethods.Count); + + // The paging convenience methods (taking a CancellationToken) are still generated because they + // instantiate the collection result directly rather than calling the suppressed protocol method. + var convenienceMethods = clientProvider.Methods + .Where(m => (m.Signature.Name == "GetItems" || m.Signature.Name == "GetItemsAsync") && + m.Signature.Parameters.Any(p => p.Type.Equals(typeof(System.Threading.CancellationToken)))) + .ToList(); + Assert.AreEqual(2, convenienceMethods.Count); + + // The paging helpers (collection result definitions) are still emitted so that the custom code + // referencing them continues to compile. + var collectionResultDefinitions = mockGenerator.Object.OutputLibrary.TypeProviders + .OfType() + .Select(t => t.Name) + .ToList(); + CollectionAssert.Contains(collectionResultDefinitions, "TestClientGetItemsCollectionResult"); + CollectionAssert.Contains(collectionResultDefinitions, "TestClientGetItemsAsyncCollectionResult"); + CollectionAssert.Contains(collectionResultDefinitions, "TestClientGetItemsCollectionResultOfT"); + CollectionAssert.Contains(collectionResultDefinitions, "TestClientGetItemsAsyncCollectionResultOfT"); + } + // Validates that a method with a struct parameter can be replaced [TestCase(true)] [TestCase(false)] diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedPagingProtocolMethodKeepsPagingHelpers/TestClient.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedPagingProtocolMethodKeepsPagingHelpers/TestClient.cs new file mode 100644 index 00000000000..34e4c7b1786 --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedPagingProtocolMethodKeepsPagingHelpers/TestClient.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.ClientModel; +using System.ClientModel.Primitives; +using Microsoft.TypeSpec.Generator.Customizations; + +namespace Sample +{ + [CodeGenSuppress("GetItems", typeof(RequestOptions))] + [CodeGenSuppress("GetItemsAsync", typeof(RequestOptions))] + public partial class TestClient + { + // Custom code that references the generated paging helper to ensure it continues to be generated. + public virtual CollectionResult GetItemsCustom(RequestOptions options) + => new TestClientGetItemsCollectionResult(this, options); + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodSkipsConvenienceMethod/TestClient.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodSkipsConvenienceMethod/TestClient.cs new file mode 100644 index 00000000000..af279a5311c --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodSkipsConvenienceMethod/TestClient.cs @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.ClientModel.Primitives; +using Microsoft.TypeSpec.Generator.Customizations; + +namespace Sample +{ + [CodeGenSuppress("HelloAgain", typeof(RequestOptions))] + [CodeGenSuppress("HelloAgainAsync", typeof(RequestOptions))] + public partial class TestClient + { + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodWithCustomCodeKeepsConvenienceMethod(Async).cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodWithCustomCodeKeepsConvenienceMethod(Async).cs new file mode 100644 index 00000000000..a43dc00338d --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodWithCustomCodeKeepsConvenienceMethod(Async).cs @@ -0,0 +1,4 @@ +public virtual async global::System.Threading.Tasks.Task HelloAgainAsync(global::System.Threading.CancellationToken cancellationToken = default) +{ + return await this.HelloAgainAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); +} diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodWithCustomCodeKeepsConvenienceMethod(Sync).cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodWithCustomCodeKeepsConvenienceMethod(Sync).cs new file mode 100644 index 00000000000..cbe70d92877 --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodWithCustomCodeKeepsConvenienceMethod(Sync).cs @@ -0,0 +1,4 @@ +public virtual global::System.ClientModel.ClientResult HelloAgain(global::System.Threading.CancellationToken cancellationToken = default) +{ + return this.HelloAgain(cancellationToken.ToRequestOptions()); +} diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodWithCustomCodeKeepsConvenienceMethod/TestClient.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodWithCustomCodeKeepsConvenienceMethod/TestClient.cs new file mode 100644 index 00000000000..80cd99288a5 --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodWithCustomCodeKeepsConvenienceMethod/TestClient.cs @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading.Tasks; +using Microsoft.TypeSpec.Generator.Customizations; + +namespace Sample +{ + [CodeGenSuppress("HelloAgain", typeof(RequestOptions))] + [CodeGenSuppress("HelloAgainAsync", typeof(RequestOptions))] + public partial class TestClient + { + public virtual ClientResult HelloAgain(RequestOptions options) + { + + } + + public virtual Task HelloAgainAsync(RequestOptions options) + { + + } + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodWithCustomOverloadSkipsConvenienceMethod/TestClient.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodWithCustomOverloadSkipsConvenienceMethod/TestClient.cs new file mode 100644 index 00000000000..e7720439d07 --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodWithCustomOverloadSkipsConvenienceMethod/TestClient.cs @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading.Tasks; +using Microsoft.TypeSpec.Generator.Customizations; + +namespace Sample +{ + [CodeGenSuppress("HelloAgain", typeof(RequestOptions))] + [CodeGenSuppress("HelloAgainAsync", typeof(RequestOptions))] + public partial class TestClient + { + public virtual ClientResult HelloAgain(string extra, RequestOptions options) + { + + } + + public virtual Task HelloAgainAsync(string extra, RequestOptions options) + { + + } + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/CodeModelGenerator.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/CodeModelGenerator.cs index c7a7574552b..3fa5cd8d5ca 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/CodeModelGenerator.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/CodeModelGenerator.cs @@ -99,7 +99,13 @@ internal set public IReadOnlyList SharedSourceDirectories => _sharedSourceDirectories; - internal IReadOnlyList CustomCodeAttributeProviders { get; } = + /// + /// The list of instances that define custom-code attributes. These attribute + /// definitions are generated into the SDK project and are made available to the compiler while it compiles + /// custom code. Derived generators can contribute additional providers via + /// . + /// + internal List CustomCodeAttributeProviders { get; } = [ new CodeGenTypeAttributeDefinition(), new CodeGenMemberAttributeDefinition(), @@ -160,6 +166,17 @@ public virtual void AddSharedSourceDirectory(string sharedSourceDirectory) _sharedSourceDirectories.Add(sharedSourceDirectory); } + /// + /// Adds a custom-code attribute provider that derived generators can use to contribute + /// generator-specific attribute definitions. The provider's attribute definition is generated into + /// the SDK project and made available to the compiler while it compiles custom code. + /// + /// The that defines the custom-code attribute. + protected void AddCustomCodeAttributeProvider(TypeProvider provider) + { + CustomCodeAttributeProviders.Add(provider); + } + private record KeptTypesInfo(HashSet TypeNames, HashSet TypeProviders); private readonly KeptTypesInfo _additionalRootTypeInfo = new([], []); diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Configuration.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Configuration.cs index d7cb00bf8b0..f1f79404b76 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Configuration.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Configuration.cs @@ -36,7 +36,8 @@ public Configuration( bool disableXmlDocs, UnreferencedTypesHandlingOption unreferencedTypesHandling, LicenseInfo? licenseInfo, - IReadOnlyList? pluginPaths = null) + IReadOnlyList? pluginPaths = null, + bool disableRoslynReduce = false) { OutputDirectory = outputPath; AdditionalConfigurationOptions = additionalConfigurationOptions; @@ -45,6 +46,7 @@ public Configuration( UnreferencedTypesHandling = unreferencedTypesHandling; LicenseInfo = licenseInfo; PluginPaths = pluginPaths; + DisableRoslynReduce = disableRoslynReduce; } /// @@ -54,6 +56,7 @@ private static class Options { public const string PackageName = "package-name"; public const string DisableXmlDocs = "disable-xml-docs"; + public const string DisableRoslynReduce = "disable-roslyn-reduce"; public const string UnreferencedTypesHandling = "unreferenced-types-handling"; public const string Plugins = "plugins"; } @@ -63,6 +66,13 @@ private static class Options /// public bool DisableXmlDocs { get; } + /// + /// Gets whether the Roslyn reduce (simplification) post-processing step is disabled. + /// Disabling it speeds up generation at the cost of less simplified output, which is + /// useful when iterating quickly. + /// + public bool DisableRoslynReduce { get; } + /// /// Gets the root output directory for the generated library. /// @@ -134,7 +144,8 @@ internal static Configuration Load(string outputPath, string? json = null) ReadOption(root, Options.DisableXmlDocs), ReadEnumOption(root, Options.UnreferencedTypesHandling), ReadLicenseInfo(root), - ReadStringArrayOption(root, Options.Plugins)); + ReadStringArrayOption(root, Options.Plugins), + ReadOption(root, Options.DisableRoslynReduce)); } private static LicenseInfo? ReadLicenseInfo(JsonElement root) @@ -165,6 +176,7 @@ internal static Configuration Load(string outputPath, string? json = null) private static readonly Dictionary _defaultBoolOptionValues = new() { { Options.DisableXmlDocs, false }, + { Options.DisableRoslynReduce, false }, }; /// @@ -174,6 +186,7 @@ internal static Configuration Load(string outputPath, string? json = null) { Options.PackageName, Options.DisableXmlDocs, + Options.DisableRoslynReduce, Options.UnreferencedTypesHandling, Options.Plugins, }; diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/PostProcessing/GeneratedCodeWorkspace.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/PostProcessing/GeneratedCodeWorkspace.cs index d90488b4c85..4588b3c4839 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/PostProcessing/GeneratedCodeWorkspace.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/PostProcessing/GeneratedCodeWorkspace.cs @@ -148,7 +148,10 @@ private async Task ProcessDocument(Document document, MemberRemoverRew } document = document.WithSyntaxRoot(root); - document = await Simplifier.ReduceAsync(document); + if (!CodeModelGenerator.Instance.Configuration.DisableRoslynReduce) + { + document = await Simplifier.ReduceAsync(document); + } // Reformat if any custom rewriters have been applied if (CodeModelGenerator.Instance.Rewriters.Count > 0) diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Properties/launchSettings.json b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Properties/launchSettings.json index 49a7be36212..695ba6fdd2a 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Properties/launchSettings.json +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Properties/launchSettings.json @@ -85,6 +85,11 @@ "commandName": "Executable", "executablePath": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.exe" }, + "http-parameters-body-root": { + "commandLineArgs": "$(SolutionDir)/TestProjects/Spector/http/parameters/body-root -g StubLibraryGenerator", + "commandName": "Executable", + "executablePath": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.exe" + }, "http-parameters-collection-format": { "commandLineArgs": "$(SolutionDir)/TestProjects/Spector/http/parameters/collection-format -g StubLibraryGenerator", "commandName": "Executable", diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Providers/MethodProvider.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Providers/MethodProvider.cs index 207354db638..1ba1bb6ec7a 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Providers/MethodProvider.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Providers/MethodProvider.cs @@ -29,6 +29,24 @@ public class MethodProvider /// public bool IsPartialMethod => Signature?.Modifiers.HasFlag(MethodSignatureModifiers.Partial) ?? false; + /// + /// Determines whether this method is suppressed via a CodeGenSuppress attribute on its + /// enclosing type. A suppressed method may still be provided by custom code, so callers that need to + /// know whether the method exists in the final output must additionally check for a custom replacement. + /// + public bool IsMethodSuppressed() + { + foreach (var attribute in EnclosingType.GetMemberSuppressionAttributes()) + { + if (TypeProvider.IsMatch(EnclosingType, Signature, attribute)) + { + return true; + } + } + + return false; + } + // for mocking #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. protected MethodProvider() diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Providers/TypeProvider.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Providers/TypeProvider.cs index fb6e6e72f25..7a3047886b6 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Providers/TypeProvider.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Providers/TypeProvider.cs @@ -832,7 +832,11 @@ private static bool IsMatch(FieldProvider fieldProvider, AttributeData attribute return name == fieldProvider.Name; } - private static bool IsMatch(TypeProvider enclosingType, MethodSignatureBase signature, AttributeData attribute) + /// + /// Determines whether the method with the given on + /// matches the given CodeGenSuppress . + /// + internal static bool IsMatch(TypeProvider enclosingType, MethodSignatureBase signature, AttributeData attribute) { ValidateArguments(enclosingType, attribute); var name = attribute.ConstructorArguments[0].Value as string; @@ -992,7 +996,7 @@ private static string GetText(SyntaxReference? syntaxReference) private static FileLinePositionSpan GetFileLinePosition(SyntaxReference? syntaxReference) => syntaxReference?.SyntaxTree.GetLocation(syntaxReference.Span).GetLineSpan() ?? default; - private IEnumerable GetMemberSuppressionAttributes() + internal IEnumerable GetMemberSuppressionAttributes() => CustomCodeView?.Attributes.Where(a => a.Data?.AttributeClass?.Name == CodeGenAttributes.CodeGenSuppressAttributeName). Select(a => a.Data!).ToList() ?? []; } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/ConfigurationTests.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/ConfigurationTests.cs index 1d81073459e..b0d402825e8 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/ConfigurationTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/ConfigurationTests.cs @@ -242,6 +242,33 @@ public void DisableDocsForField() Assert.AreEqual("public int _field;\n", writer.ToString(false)); } + [Test] + public void DisableRoslynReduce_ParsedFromConfig() + { + var mockJson = @"{ + ""output-folder"": ""outputFolder"", + ""package-name"": ""libraryName"", + ""disable-roslyn-reduce"": true + }"; + + MockHelpers.LoadMockGenerator(configuration: mockJson); + + Assert.IsTrue(CodeModelGenerator.Instance.Configuration.DisableRoslynReduce); + } + + [Test] + public void DisableRoslynReduce_DefaultsToFalse() + { + var mockJson = @"{ + ""output-folder"": ""outputFolder"", + ""package-name"": ""libraryName"" + }"; + + MockHelpers.LoadMockGenerator(configuration: mockJson); + + Assert.IsFalse(CodeModelGenerator.Instance.Configuration.DisableRoslynReduce); + } + [Test] public void CanAddLicenseInfo() { diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/GeneratorTests.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/GeneratorTests.cs index bced881740b..33c81f262c9 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/GeneratorTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/GeneratorTests.cs @@ -100,6 +100,26 @@ public void RemoveVisitorByNameRemovesAllMatchingInstances() Assert.IsInstanceOf(mockGenerator.Visitors[0]); } + [Test] + public void HasDefaultCustomCodeAttributeProviders() + { + var mockGenerator = new TestGenerator(); + Assert.AreEqual(4, mockGenerator.CustomCodeAttributeProviders.Count); + } + + [Test] + public void CanAddCustomCodeAttributeProvider() + { + var mockGenerator = new TestGenerator(); + var initialCount = mockGenerator.CustomCodeAttributeProviders.Count; + + var provider = new TestTypeProvider(); + mockGenerator.AddCustomCodeAttributeProviderForTest(provider); + + Assert.AreEqual(initialCount + 1, mockGenerator.CustomCodeAttributeProviders.Count); + Assert.AreSame(provider, mockGenerator.CustomCodeAttributeProviders[^1]); + } + private class DerivedTestLibraryVisitor : TestLibraryVisitor { } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/ModelCustomizationTests.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/ModelCustomizationTests.cs index 5cdc9161163..9033ed9b667 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/ModelCustomizationTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/ModelCustomizationTests.cs @@ -1815,6 +1815,38 @@ public async Task CanReadPropertyAttributes() Assert.AreEqual(1, fieldObsoleteAttr.Arguments.Count); } + [Test] + public async Task CanReadCustomCodeAttributeFromRegisteredProvider() + { + // A derived generator contributes a generator-specific custom-code attribute via the extension point. + var customAttributeProvider = new TestCustomCodeAttributeDefinition(); + var generator = new TestGenerator(); + generator.AddCustomCodeAttributeProviderForTest(customAttributeProvider); + CollectionAssert.Contains(generator.CustomCodeAttributeProviders, customAttributeProvider); + + await MockHelpers.LoadMockGeneratorAsync( + compilation: async () => + { + var compilation = await Helpers.GetCompilationFromDirectoryAsync(); + // Mirror CSharpGen: the contributed attribute definition is emitted into the custom-code + // compilation so that custom code referencing it compiles and can be parsed. + return compilation.AddSyntaxTrees(GeneratedCodeWorkspace.GetTree(customAttributeProvider)); + }); + + var inputModel = InputFactory.Model("mockInputModel"); + var modelProvider = new ModelProvider(inputModel); + var customCodeView = modelProvider.CustomCodeView; + + Assert.IsNotNull(customCodeView); + + // Validate that the parsed type registers the custom-code attribute contributed by the provider. + var customAttr = customCodeView!.Attributes.Single(a => a.Type.Name == "CodeGenCustomAttribute"); + Assert.AreEqual(AttributeNamespace, customAttr.Type.Namespace); + Assert.AreEqual(1, customAttr.Arguments.Count); + } + + private const string AttributeNamespace = TestCustomCodeAttributeDefinition.AttributeNamespace; + private class TestNameVisitor : NameVisitor { public TypeProvider? InvokeVisit(TypeProvider type) diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/TestData/ModelCustomizationTests/CanReadCustomCodeAttributeFromRegisteredProvider/MockInputModel.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/TestData/ModelCustomizationTests/CanReadCustomCodeAttributeFromRegisteredProvider/MockInputModel.cs new file mode 100644 index 00000000000..fcc78cfc9a6 --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/TestData/ModelCustomizationTests/CanReadCustomCodeAttributeFromRegisteredProvider/MockInputModel.cs @@ -0,0 +1,11 @@ +#nullable disable + +using Sample.Customizations; + +namespace Sample.Models +{ + [CodeGenCustom("CustomValue")] + public partial class MockInputModel + { + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/TestHelpers/TestCustomCodeAttributeDefinition.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/TestHelpers/TestCustomCodeAttributeDefinition.cs new file mode 100644 index 00000000000..fc7733324bc --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/TestHelpers/TestCustomCodeAttributeDefinition.cs @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.IO; +using Microsoft.TypeSpec.Generator.Primitives; +using Microsoft.TypeSpec.Generator.Providers; +using Microsoft.TypeSpec.Generator.Statements; +using static Microsoft.TypeSpec.Generator.Snippets.Snippet; + +namespace Microsoft.TypeSpec.Generator.Tests +{ + /// + /// A sample generator-specific custom-code attribute definition that a derived generator could contribute + /// via AddCustomCodeAttributeProvider. Used to validate that custom code referencing the attribute is + /// parsed and the attribute is registered on the parsed type. + /// + public class TestCustomCodeAttributeDefinition : TypeProvider + { + public const string AttributeNamespace = "Sample.Customizations"; + + protected override string BuildRelativeFilePath() => Path.Combine("src", "Generated", "Internal", $"{Name}.cs"); + + protected override string BuildName() => "CodeGenCustomAttribute"; + + protected override string BuildNamespace() => AttributeNamespace; + + protected override TypeSignatureModifiers BuildDeclarationModifiers() => + TypeSignatureModifiers.Public | TypeSignatureModifiers.Class; + + protected internal override CSharpType[] BuildImplements() => [typeof(Attribute)]; + + protected internal override PropertyProvider[] BuildProperties() => + [ + new PropertyProvider( + null, + MethodSignatureModifiers.Public, + typeof(string), + "Value", + new AutoPropertyBody(false), + this) + ]; + + protected internal override ConstructorProvider[] BuildConstructors() + { + var parameter = new ParameterProvider("value", $"The custom value.", typeof(string)); + + return + [ + new ConstructorProvider( + new ConstructorSignature( + Type, + null, + MethodSignatureModifiers.Public, + [parameter]), + This.Property("Value").Assign(parameter).Terminate(), + this) + ]; + } + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/TestHelpers/TestGenerator.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/TestHelpers/TestGenerator.cs index a96c2c3b3a2..ba191712d0b 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/TestHelpers/TestGenerator.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/TestHelpers/TestGenerator.cs @@ -2,6 +2,7 @@ // Licensed under the MIT License. using System.Collections.Generic; +using Microsoft.TypeSpec.Generator.Providers; namespace Microsoft.TypeSpec.Generator.Tests { @@ -10,5 +11,8 @@ public class TestGenerator : CodeModelGenerator public TestGenerator() { } + + public void AddCustomCodeAttributeProviderForTest(TypeProvider provider) + => AddCustomCodeAttributeProvider(provider); } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/Configuration.json new file mode 100644 index 00000000000..ae9cd5f165f --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/Configuration.json @@ -0,0 +1,3 @@ +{ + "package-name": "Parameters.BodyRoot" +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/Parameters.BodyRoot.NuGet.targets b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/Parameters.BodyRoot.NuGet.targets new file mode 100644 index 00000000000..9df53f09f6f --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/Parameters.BodyRoot.NuGet.targets @@ -0,0 +1,6 @@ + + + + + diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/Parameters.BodyRoot.slnx b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/Parameters.BodyRoot.slnx new file mode 100644 index 00000000000..ce8d57436e8 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/Parameters.BodyRoot.slnx @@ -0,0 +1,3 @@ + + + diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/BodyRootClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/BodyRootClient.cs new file mode 100644 index 00000000000..d78b3acea38 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/BodyRootClient.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Diagnostics.CodeAnalysis; +using System.Threading; +using System.Threading.Tasks; + +namespace Parameters.BodyRoot +{ + public partial class BodyRootClient + { + public BodyRootClient() : this(new Uri("http://localhost:3000"), new BodyRootClientOptions()) => throw null; + + internal BodyRootClient(AuthenticationPolicy authenticationPolicy, Uri endpoint, BodyRootClientOptions options) => throw null; + + public BodyRootClient(Uri endpoint, BodyRootClientOptions options) : this(null, endpoint, options) => throw null; + + [Experimental("SCME0002")] + public BodyRootClient(BodyRootClientSettings settings) : this(AuthenticationPolicy.Create(settings), settings?.Endpoint, settings?.Options) => throw null; + + public ClientPipeline Pipeline => throw null; + + public virtual ClientResult Nested(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual Task NestedAsync(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual ClientResult Nested(NestedParameterBody body, CancellationToken cancellationToken = default) => throw null; + + public virtual Task NestedAsync(NestedParameterBody body, CancellationToken cancellationToken = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/BodyRootClientOptions.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/BodyRootClientOptions.cs new file mode 100644 index 00000000000..ef48984732a --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/BodyRootClientOptions.cs @@ -0,0 +1,18 @@ +// + +#nullable disable + +using System.ClientModel.Primitives; +using System.Diagnostics.CodeAnalysis; +using Microsoft.Extensions.Configuration; + +namespace Parameters.BodyRoot +{ + public partial class BodyRootClientOptions : ClientPipelineOptions + { + public BodyRootClientOptions() => throw null; + + [Experimental("SCME0002")] + internal BodyRootClientOptions(IConfigurationSection section) : base(section) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/BodyRootClientSettings.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/BodyRootClientSettings.cs new file mode 100644 index 00000000000..109b1047c05 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/BodyRootClientSettings.cs @@ -0,0 +1,29 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Diagnostics.CodeAnalysis; +using Microsoft.Extensions.Configuration; + +namespace Parameters.BodyRoot +{ + [Experimental("SCME0002")] + public partial class BodyRootClientSettings : ClientSettings + { + public Uri Endpoint + { + get => throw null; + set => throw null; + } + + public BodyRootClientOptions Options + { + get => throw null; + set => throw null; + } + + protected override void BindCore(IConfigurationSection section) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/BodyRootModel.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/BodyRootModel.Serialization.cs new file mode 100644 index 00000000000..d78494b73cd --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/BodyRootModel.Serialization.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Parameters.BodyRoot +{ + public partial class BodyRootModel : IJsonModel + { + protected virtual BodyRootModel PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + BodyRootModel IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + public static implicit operator BinaryContent(BodyRootModel bodyRootModel) => throw null; + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + BodyRootModel IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected virtual BodyRootModel JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/BodyRootModel.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/BodyRootModel.cs new file mode 100644 index 00000000000..2dff18065c2 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/BodyRootModel.cs @@ -0,0 +1,29 @@ +// + +#nullable disable + +namespace Parameters.BodyRoot +{ + public partial class BodyRootModel + { + public BodyRootModel() => throw null; + + public string Category + { + get => throw null; + set => throw null; + } + + public string LinkType + { + get => throw null; + set => throw null; + } + + public bool? WasSuccessful + { + get => throw null; + set => throw null; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/NestedParameterBody.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/NestedParameterBody.Serialization.cs new file mode 100644 index 00000000000..4a61cca774d --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/NestedParameterBody.Serialization.cs @@ -0,0 +1,33 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Parameters.BodyRoot +{ + public partial class NestedParameterBody : IJsonModel + { + internal NestedParameterBody() => throw null; + + protected virtual NestedParameterBody PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + NestedParameterBody IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + NestedParameterBody IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected virtual NestedParameterBody JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/NestedParameterBody.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/NestedParameterBody.cs new file mode 100644 index 00000000000..3598264b2a5 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/NestedParameterBody.cs @@ -0,0 +1,13 @@ +// + +#nullable disable + +namespace Parameters.BodyRoot +{ + public partial class NestedParameterBody + { + public NestedParameterBody(BodyRootModel bodyRootParameters) => throw null; + + public BodyRootModel BodyRootParameters => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/ParametersBodyRootContext.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/ParametersBodyRootContext.cs new file mode 100644 index 00000000000..baef5ec78fe --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/ParametersBodyRootContext.cs @@ -0,0 +1,14 @@ +// + +#nullable disable + +using System.ClientModel.Primitives; + +namespace Parameters.BodyRoot +{ + [ModelReaderWriterBuildable(typeof(BodyRootModel))] + [ModelReaderWriterBuildable(typeof(NestedParameterBody))] + public partial class ParametersBodyRootContext : ModelReaderWriterContext + { + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/ParametersBodyRootModelFactory.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/ParametersBodyRootModelFactory.cs new file mode 100644 index 00000000000..347b2cb24c8 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/ParametersBodyRootModelFactory.cs @@ -0,0 +1,13 @@ +// + +#nullable disable + +namespace Parameters.BodyRoot +{ + public static partial class ParametersBodyRootModelFactory + { + public static BodyRootModel BodyRootModel(string category = default, string linkType = default, bool? wasSuccessful = default) => throw null; + + public static NestedParameterBody NestedParameterBody(BodyRootModel bodyRootParameters = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/schema/ConfigurationSchema.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/schema/ConfigurationSchema.json new file mode 100644 index 00000000000..9b632a36555 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/schema/ConfigurationSchema.json @@ -0,0 +1,40 @@ +{ + "type": "object", + "properties": { + "Clients": { + "type": "object", + "properties": { + "BodyRootClient": { + "type": "object", + "description": "Configuration for BodyRootClient.", + "properties": { + "Endpoint": { + "type": "string", + "format": "uri", + "description": "Gets or sets the Endpoint." + }, + "Credential": { + "$ref": "#/definitions/credential" + }, + "Options": { + "$ref": "#/definitions/bodyRootClientOptions" + } + } + } + }, + "additionalProperties": { + "type": "object", + "description": "Configuration for a named client instance." + } + } + }, + "definitions": { + "bodyRootClientOptions": { + "allOf": [ + { + "$ref": "#/definitions/options" + } + ] + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Parameters.BodyRoot.csproj b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Parameters.BodyRoot.csproj new file mode 100644 index 00000000000..dc8fb18480d --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Parameters.BodyRoot.csproj @@ -0,0 +1,20 @@ + + + This is the Parameters.BodyRoot client library for developing .NET applications with rich experience. + SDK Code Generation Parameters.BodyRoot + 1.0.0-beta.1 + Parameters.BodyRoot + netstandard2.0;net8.0 + latest + true + + + + + + + + + + + diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/tspCodeModel.json new file mode 100644 index 00000000000..74560ddc5f0 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/tspCodeModel.json @@ -0,0 +1,355 @@ +{ + "name": "Parameters.BodyRoot", + "apiVersions": [], + "enums": [], + "constants": [ + { + "$id": "1", + "kind": "constant", + "name": "NestedContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "2", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [], + "isExactName": false + } + ], + "models": [ + { + "$id": "3", + "kind": "model", + "name": "BodyRootModel", + "namespace": "Parameters.BodyRoot", + "crossLanguageDefinitionId": "Parameters.BodyRoot.BodyRootModel", + "usage": "Input,Json", + "decorators": [], + "serializationOptions": { + "json": { + "name": "BodyRootModel" + } + }, + "isExactName": false, + "properties": [ + { + "$id": "4", + "kind": "property", + "name": "category", + "serializedName": "category", + "type": { + "$id": "5", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Parameters.BodyRoot.BodyRootModel.category", + "serializationOptions": { + "json": { + "name": "category" + } + }, + "isHttpMetadata": false, + "isExactName": false + }, + { + "$id": "6", + "kind": "property", + "name": "linkType", + "serializedName": "linkType", + "type": { + "$id": "7", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Parameters.BodyRoot.BodyRootModel.linkType", + "serializationOptions": { + "json": { + "name": "linkType" + } + }, + "isHttpMetadata": false, + "isExactName": false + }, + { + "$id": "8", + "kind": "property", + "name": "wasSuccessful", + "serializedName": "wasSuccessful", + "type": { + "$id": "9", + "kind": "boolean", + "name": "boolean", + "crossLanguageDefinitionId": "TypeSpec.boolean", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Parameters.BodyRoot.BodyRootModel.wasSuccessful", + "serializationOptions": { + "json": { + "name": "wasSuccessful" + } + }, + "isHttpMetadata": false, + "isExactName": false + } + ] + }, + { + "$id": "10", + "kind": "model", + "name": "NestedParameterBody", + "namespace": "Parameters.BodyRoot", + "crossLanguageDefinitionId": "Parameters.BodyRoot.nested.Parameter.body.anonymous", + "usage": "Input", + "decorators": [], + "serializationOptions": {}, + "isExactName": false, + "properties": [ + { + "$id": "11", + "kind": "property", + "name": "bodyRootParameters", + "type": { + "$ref": "3" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Parameters.BodyRoot.nested.Parameter.body.anonymous.bodyRootParameters", + "serializationOptions": {}, + "isHttpMetadata": false, + "isExactName": false + } + ] + } + ], + "clients": [ + { + "$id": "12", + "kind": "client", + "name": "BodyRootClient", + "isExactName": false, + "namespace": "Parameters.BodyRoot", + "doc": "Test for @bodyRoot parameter patterns.", + "methods": [ + { + "$id": "13", + "kind": "basic", + "name": "nested", + "isExactName": false, + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "14", + "name": "nested", + "isExactName": false, + "resourceName": "BodyRoot", + "accessibility": "public", + "parameters": [ + { + "$id": "15", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "1" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Parameters.BodyRoot.nested.contentType", + "methodParameterSegments": [ + { + "$id": "16", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "1" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Parameters.BodyRoot.nested.contentType", + "readOnly": false, + "access": "public", + "decorators": [], + "isExactName": false + } + ], + "isExactName": false + }, + { + "$id": "17", + "kind": "body", + "name": "bodyRootParameters", + "serializedName": "bodyRootParameters", + "type": { + "$ref": "3" + }, + "isApiVersion": false, + "contentTypes": [ + "application/json" + ], + "defaultContentType": "application/json", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Parameters.BodyRoot.nested.Parameter.body.anonymous.bodyRootParameters", + "methodParameterSegments": [ + { + "$id": "18", + "kind": "method", + "name": "body", + "serializedName": "body", + "type": { + "$ref": "10" + }, + "location": "", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Parameters.BodyRoot.nested.body", + "readOnly": false, + "access": "public", + "decorators": [], + "isExactName": false + }, + { + "$id": "19", + "kind": "method", + "name": "bodyRootParameters", + "serializedName": "bodyRootParameters", + "type": { + "$ref": "3" + }, + "location": "", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Parameters.BodyRoot.nested.Parameter.body.anonymous.bodyRootParameters", + "readOnly": false, + "access": "public", + "decorators": [], + "isExactName": false + } + ], + "isExactName": false, + "serializationOptions": { + "json": { + "name": "bodyRootParameters" + } + } + } + ], + "responses": [ + { + "statusCodes": [ + 204 + ], + "headers": [], + "isErrorResponse": false, + "serializationOptions": {} + } + ], + "httpMethod": "POST", + "uri": "{endpoint}", + "path": "/parameters/body-root/nested", + "requestMediaTypes": [ + "application/json" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Parameters.BodyRoot.nested", + "decorators": [], + "namespace": "Parameters.BodyRoot" + }, + "parameters": [ + { + "$ref": "18" + }, + { + "$ref": "16" + } + ], + "response": {}, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Parameters.BodyRoot.nested" + } + ], + "parameters": [ + { + "$id": "20", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "21", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "22", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "http://localhost:3000" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Parameters.BodyRoot.endpoint", + "isExactName": false + } + ], + "initializedBy": 1, + "decorators": [], + "crossLanguageDefinitionId": "Parameters.BodyRoot", + "apiVersions": [], + "isMultiServiceClient": false + } + ] +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/query/src/Generated/QueryClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/query/src/Generated/QueryClient.cs index 6a4be8cbeed..862d4747af9 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/query/src/Generated/QueryClient.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/query/src/Generated/QueryClient.cs @@ -22,5 +22,7 @@ public partial class QueryClient public ClientPipeline Pipeline => throw null; public virtual Constant GetConstantClient() => throw null; + + public virtual SpecialChar GetSpecialCharClient() => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/query/src/Generated/SpecialChar.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/query/src/Generated/SpecialChar.cs new file mode 100644 index 00000000000..02f488d8034 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/query/src/Generated/SpecialChar.cs @@ -0,0 +1,29 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; + +namespace Parameters.Query +{ + public partial class SpecialChar + { + protected SpecialChar() => throw null; + + internal SpecialChar(ClientPipeline pipeline, Uri endpoint) => throw null; + + public ClientPipeline Pipeline => throw null; + + public virtual ClientResult DollarSign(string filter, RequestOptions options) => throw null; + + public virtual Task DollarSignAsync(string filter, RequestOptions options) => throw null; + + public virtual ClientResult DollarSign(string filter, CancellationToken cancellationToken = default) => throw null; + + public virtual Task DollarSignAsync(string filter, CancellationToken cancellationToken = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/query/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/query/tspCodeModel.json index 188b51262ae..93d44df48b3 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/query/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/query/tspCodeModel.json @@ -221,6 +221,148 @@ "$ref": "5" }, "isMultiServiceClient": false + }, + { + "$id": "17", + "kind": "client", + "name": "SpecialChar", + "isExactName": false, + "namespace": "Parameters.Query", + "doc": "Special char query parameter verification", + "methods": [ + { + "$id": "18", + "kind": "basic", + "name": "dollarSign", + "isExactName": false, + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "19", + "name": "dollarSign", + "isExactName": false, + "resourceName": "SpecialChar", + "accessibility": "public", + "parameters": [ + { + "$id": "20", + "kind": "query", + "name": "filter", + "serializedName": "$filter", + "type": { + "$id": "21", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "optional": false, + "scope": "Method", + "decorators": [], + "crossLanguageDefinitionId": "Parameters.Query.SpecialChar.dollarSign.filter", + "readOnly": false, + "methodParameterSegments": [ + { + "$id": "22", + "kind": "method", + "name": "filter", + "serializedName": "$filter", + "type": { + "$id": "23", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Query", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Parameters.Query.SpecialChar.dollarSign.filter", + "readOnly": false, + "access": "public", + "decorators": [], + "isExactName": false + } + ], + "isExactName": false + } + ], + "responses": [ + { + "statusCodes": [ + 204 + ], + "headers": [], + "isErrorResponse": false, + "serializationOptions": {} + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/parameters/query/special-char/dollarSign", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Parameters.Query.SpecialChar.dollarSign", + "decorators": [], + "namespace": "Parameters.Query" + }, + "parameters": [ + { + "$ref": "22" + } + ], + "response": {}, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Parameters.Query.SpecialChar.dollarSign" + } + ], + "parameters": [ + { + "$id": "24", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "25", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "26", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "http://localhost:3000" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Parameters.Query.SpecialChar.endpoint", + "isExactName": false + } + ], + "initializedBy": 0, + "decorators": [], + "crossLanguageDefinitionId": "Parameters.Query.SpecialChar", + "apiVersions": [], + "parent": { + "$ref": "5" + }, + "isMultiServiceClient": false } ], "isMultiServiceClient": false diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/enum-discriminator/src/Generated/Models/DogKind.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/enum-discriminator/src/Generated/Models/DogKind.cs index 08c207dedc0..bc84debea39 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/enum-discriminator/src/Generated/Models/DogKind.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/enum-discriminator/src/Generated/Models/DogKind.cs @@ -7,7 +7,7 @@ namespace _Type.Model.Inheritance.EnumDiscriminator { - public readonly partial struct DogKind : IEquatable + internal readonly partial struct DogKind : IEquatable { public DogKind(string value) => throw null; diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/enum-discriminator/src/Generated/Models/SnakeKind.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/enum-discriminator/src/Generated/Models/SnakeKind.cs index 8e678733c92..351935ee0ca 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/enum-discriminator/src/Generated/Models/SnakeKind.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/enum-discriminator/src/Generated/Models/SnakeKind.cs @@ -4,7 +4,7 @@ namespace _Type.Model.Inheritance.EnumDiscriminator { - public enum SnakeKind + internal enum SnakeKind { /// Species cobra. Cobra diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Fish.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Fish.Serialization.cs new file mode 100644 index 00000000000..7ed655a1c0e --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Fish.Serialization.cs @@ -0,0 +1,39 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + [PersistableModelProxy(typeof(UnknownFish))] + public abstract partial class Fish : IJsonModel + { + internal Fish() => throw null; + + protected virtual Fish PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + Fish IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + public static implicit operator BinaryContent(Fish fish) => throw null; + + public static explicit operator Fish(ClientResult result) => throw null; + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + Fish IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected virtual Fish JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Fish.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Fish.cs new file mode 100644 index 00000000000..26a9bca69ca --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Fish.cs @@ -0,0 +1,28 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + public abstract partial class Fish + { + private protected Fish(string kind, int size) => throw null; + + internal Fish(string kind, int size, IDictionary additionalBinaryDataProperties) => throw null; + + internal string Kind + { + get => throw null; + set => throw null; + } + + public int Size + { + get => throw null; + set => throw null; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownFish.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownFish.Serialization.cs new file mode 100644 index 00000000000..0f803642de8 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownFish.Serialization.cs @@ -0,0 +1,33 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + internal partial class UnknownFish : Fish, IJsonModel + { + internal UnknownFish() => throw null; + + protected override Fish PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + Fish IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + Fish IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected override Fish JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownFish.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownFish.cs new file mode 100644 index 00000000000..b2b66b486c0 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownFish.cs @@ -0,0 +1,14 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + internal partial class UnknownFish : Fish + { + internal UnknownFish(string kind, int size, IDictionary additionalBinaryDataProperties) : base(kind ?? "unknown", size, additionalBinaryDataProperties) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/_TypeModelInheritanceSingleDiscriminatorContext.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/_TypeModelInheritanceSingleDiscriminatorContext.cs index 66003f92303..be4653744b5 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/_TypeModelInheritanceSingleDiscriminatorContext.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/_TypeModelInheritanceSingleDiscriminatorContext.cs @@ -9,12 +9,14 @@ namespace _Type.Model.Inheritance.SingleDiscriminator [ModelReaderWriterBuildable(typeof(Bird))] [ModelReaderWriterBuildable(typeof(Dinosaur))] [ModelReaderWriterBuildable(typeof(Eagle))] + [ModelReaderWriterBuildable(typeof(Fish))] [ModelReaderWriterBuildable(typeof(Goose))] [ModelReaderWriterBuildable(typeof(SeaGull))] [ModelReaderWriterBuildable(typeof(Sparrow))] [ModelReaderWriterBuildable(typeof(TRex))] [ModelReaderWriterBuildable(typeof(UnknownBird))] [ModelReaderWriterBuildable(typeof(UnknownDinosaur))] + [ModelReaderWriterBuildable(typeof(UnknownFish))] public partial class _TypeModelInheritanceSingleDiscriminatorContext : ModelReaderWriterContext { } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClient.cs index d6a1a0eb170..e3ad8523343 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClient.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClient.cs @@ -79,5 +79,21 @@ public partial class SingleDiscriminatorClient public virtual ClientResult GetLegacyModel(CancellationToken cancellationToken = default) => throw null; public virtual Task> GetLegacyModelAsync(CancellationToken cancellationToken = default) => throw null; + + public virtual ClientResult GetNoSubtypesModel(RequestOptions options) => throw null; + + public virtual Task GetNoSubtypesModelAsync(RequestOptions options) => throw null; + + public virtual ClientResult GetNoSubtypesModel(CancellationToken cancellationToken = default) => throw null; + + public virtual Task> GetNoSubtypesModelAsync(CancellationToken cancellationToken = default) => throw null; + + public virtual ClientResult PutNoSubtypesModel(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual Task PutNoSubtypesModelAsync(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual ClientResult PutNoSubtypesModel(Fish input, CancellationToken cancellationToken = default) => throw null; + + public virtual Task PutNoSubtypesModelAsync(Fish input, CancellationToken cancellationToken = default) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/TypeModelInheritanceSingleDiscriminatorModelFactory.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/TypeModelInheritanceSingleDiscriminatorModelFactory.cs index a76389a6425..733864f2b9e 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/TypeModelInheritanceSingleDiscriminatorModelFactory.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/TypeModelInheritanceSingleDiscriminatorModelFactory.cs @@ -21,5 +21,7 @@ public static partial class TypeModelInheritanceSingleDiscriminatorModelFactory public static Dinosaur Dinosaur(string kind = default, int size = default) => throw null; public static TRex TRex(int size = default) => throw null; + + public static Fish Fish(string kind = default, int size = default) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/tspCodeModel.json index ad84c330c65..380d9194562 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/tspCodeModel.json @@ -206,11 +206,45 @@ "value": "application/json", "decorators": [], "isExactName": false + }, + { + "$id": "25", + "kind": "constant", + "name": "GetModelAccept7", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "26", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [], + "isExactName": false + }, + { + "$id": "27", + "kind": "constant", + "name": "GetModelAccept8", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "28", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [], + "isExactName": false } ], "models": [ { - "$id": "25", + "$id": "29", "kind": "model", "name": "Bird", "namespace": "Type.Model.Inheritance.SingleDiscriminator", @@ -225,12 +259,12 @@ }, "isExactName": false, "discriminatorProperty": { - "$id": "26", + "$id": "30", "kind": "property", "name": "kind", "serializedName": "kind", "type": { - "$id": "27", + "$id": "31", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -252,15 +286,15 @@ }, "properties": [ { - "$ref": "26" + "$ref": "30" }, { - "$id": "28", + "$id": "32", "kind": "property", "name": "wingspan", "serializedName": "wingspan", "type": { - "$id": "29", + "$id": "33", "kind": "int32", "name": "int32", "crossLanguageDefinitionId": "TypeSpec.int32", @@ -283,7 +317,7 @@ ], "discriminatedSubtypes": { "seagull": { - "$id": "30", + "$id": "34", "kind": "model", "name": "SeaGull", "namespace": "Type.Model.Inheritance.SingleDiscriminator", @@ -299,11 +333,11 @@ }, "isExactName": false, "baseModel": { - "$ref": "25" + "$ref": "29" }, "properties": [ { - "$id": "31", + "$id": "35", "kind": "property", "name": "kind", "serializedName": "kind", @@ -327,7 +361,7 @@ ] }, "sparrow": { - "$id": "32", + "$id": "36", "kind": "model", "name": "Sparrow", "namespace": "Type.Model.Inheritance.SingleDiscriminator", @@ -343,11 +377,11 @@ }, "isExactName": false, "baseModel": { - "$ref": "25" + "$ref": "29" }, "properties": [ { - "$id": "33", + "$id": "37", "kind": "property", "name": "kind", "serializedName": "kind", @@ -371,7 +405,7 @@ ] }, "goose": { - "$id": "34", + "$id": "38", "kind": "model", "name": "Goose", "namespace": "Type.Model.Inheritance.SingleDiscriminator", @@ -387,11 +421,11 @@ }, "isExactName": false, "baseModel": { - "$ref": "25" + "$ref": "29" }, "properties": [ { - "$id": "35", + "$id": "39", "kind": "property", "name": "kind", "serializedName": "kind", @@ -415,7 +449,7 @@ ] }, "eagle": { - "$id": "36", + "$id": "40", "kind": "model", "name": "Eagle", "namespace": "Type.Model.Inheritance.SingleDiscriminator", @@ -431,11 +465,11 @@ }, "isExactName": false, "baseModel": { - "$ref": "25" + "$ref": "29" }, "properties": [ { - "$id": "37", + "$id": "41", "kind": "property", "name": "kind", "serializedName": "kind", @@ -457,16 +491,16 @@ "isExactName": false }, { - "$id": "38", + "$id": "42", "kind": "property", "name": "friends", "serializedName": "friends", "type": { - "$id": "39", + "$id": "43", "kind": "array", "name": "ArrayBird", "valueType": { - "$ref": "25" + "$ref": "29" }, "crossLanguageDefinitionId": "TypeSpec.Array", "decorators": [] @@ -486,22 +520,22 @@ "isExactName": false }, { - "$id": "40", + "$id": "44", "kind": "property", "name": "hate", "serializedName": "hate", "type": { - "$id": "41", + "$id": "45", "kind": "dict", "keyType": { - "$id": "42", + "$id": "46", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", "decorators": [] }, "valueType": { - "$ref": "25" + "$ref": "29" }, "decorators": [] }, @@ -520,12 +554,12 @@ "isExactName": false }, { - "$id": "43", + "$id": "47", "kind": "property", "name": "partner", "serializedName": "partner", "type": { - "$ref": "25" + "$ref": "29" }, "optional": true, "readOnly": false, @@ -546,19 +580,19 @@ } }, { - "$ref": "30" + "$ref": "34" }, { - "$ref": "32" + "$ref": "36" }, { - "$ref": "34" + "$ref": "38" }, { - "$ref": "36" + "$ref": "40" }, { - "$id": "44", + "$id": "48", "kind": "model", "name": "Dinosaur", "namespace": "Type.Model.Inheritance.SingleDiscriminator", @@ -573,13 +607,13 @@ }, "isExactName": false, "discriminatorProperty": { - "$id": "45", + "$id": "49", "kind": "property", "name": "kind", "serializedName": "kind", "doc": "Discriminator property for Dinosaur.", "type": { - "$id": "46", + "$id": "50", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -601,15 +635,15 @@ }, "properties": [ { - "$ref": "45" + "$ref": "49" }, { - "$id": "47", + "$id": "51", "kind": "property", "name": "size", "serializedName": "size", "type": { - "$id": "48", + "$id": "52", "kind": "int32", "name": "int32", "crossLanguageDefinitionId": "TypeSpec.int32", @@ -632,7 +666,7 @@ ], "discriminatedSubtypes": { "t-rex": { - "$id": "49", + "$id": "53", "kind": "model", "name": "TRex", "namespace": "Type.Model.Inheritance.SingleDiscriminator", @@ -648,11 +682,11 @@ }, "isExactName": false, "baseModel": { - "$ref": "44" + "$ref": "48" }, "properties": [ { - "$id": "50", + "$id": "54", "kind": "property", "name": "kind", "serializedName": "kind", @@ -678,12 +712,85 @@ } }, { - "$ref": "49" + "$ref": "53" + }, + { + "$id": "55", + "kind": "model", + "name": "Fish", + "namespace": "Type.Model.Inheritance.SingleDiscriminator", + "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.Fish", + "usage": "Input,Output,Json", + "doc": "A discriminated model with no defined subtypes. The discriminator is declared but no models extend it.", + "decorators": [], + "serializationOptions": { + "json": { + "name": "Fish" + } + }, + "isExactName": false, + "discriminatorProperty": { + "$id": "56", + "kind": "property", + "name": "kind", + "serializedName": "kind", + "type": { + "$id": "57", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": true, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.Fish.kind", + "serializationOptions": { + "json": { + "name": "kind" + } + }, + "isHttpMetadata": false, + "isExactName": false + }, + "properties": [ + { + "$ref": "56" + }, + { + "$id": "58", + "kind": "property", + "name": "size", + "serializedName": "size", + "type": { + "$id": "59", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.Fish.size", + "serializationOptions": { + "json": { + "name": "size" + } + }, + "isHttpMetadata": false, + "isExactName": false + } + ] } ], "clients": [ { - "$id": "51", + "$id": "60", "kind": "client", "name": "SingleDiscriminatorClient", "isExactName": false, @@ -691,21 +798,21 @@ "doc": "Illustrates inheritance with single discriminator.", "methods": [ { - "$id": "52", + "$id": "61", "kind": "basic", "name": "getModel", "isExactName": false, "accessibility": "public", "apiVersions": [], "operation": { - "$id": "53", + "$id": "62", "name": "getModel", "isExactName": false, "resourceName": "SingleDiscriminator", "accessibility": "public", "parameters": [ { - "$id": "54", + "$id": "63", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -721,7 +828,7 @@ "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.getModel.accept", "methodParameterSegments": [ { - "$id": "55", + "$id": "64", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -748,7 +855,7 @@ 200 ], "bodyType": { - "$ref": "25" + "$ref": "29" }, "headers": [], "isErrorResponse": false, @@ -774,12 +881,12 @@ }, "parameters": [ { - "$ref": "55" + "$ref": "64" } ], "response": { "type": { - "$ref": "25" + "$ref": "29" } }, "isOverride": false, @@ -788,21 +895,21 @@ "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.getModel" }, { - "$id": "56", + "$id": "65", "kind": "basic", "name": "putModel", "isExactName": false, "accessibility": "public", "apiVersions": [], "operation": { - "$id": "57", + "$id": "66", "name": "putModel", "isExactName": false, "resourceName": "SingleDiscriminator", "accessibility": "public", "parameters": [ { - "$id": "58", + "$id": "67", "kind": "header", "name": "contentType", "serializedName": "Content-Type", @@ -819,7 +926,7 @@ "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.putModel.contentType", "methodParameterSegments": [ { - "$id": "59", + "$id": "68", "kind": "method", "name": "contentType", "serializedName": "Content-Type", @@ -841,12 +948,12 @@ "isExactName": false }, { - "$id": "60", + "$id": "69", "kind": "body", "name": "input", "serializedName": "input", "type": { - "$ref": "25" + "$ref": "29" }, "isApiVersion": false, "contentTypes": [ @@ -860,12 +967,12 @@ "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.putModel.input", "methodParameterSegments": [ { - "$id": "61", + "$id": "70", "kind": "method", "name": "input", "serializedName": "input", "type": { - "$ref": "25" + "$ref": "29" }, "location": "Body", "isApiVersion": false, @@ -911,10 +1018,10 @@ }, "parameters": [ { - "$ref": "61" + "$ref": "70" }, { - "$ref": "59" + "$ref": "68" } ], "response": {}, @@ -924,21 +1031,21 @@ "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.putModel" }, { - "$id": "62", + "$id": "71", "kind": "basic", "name": "getRecursiveModel", "isExactName": false, "accessibility": "public", "apiVersions": [], "operation": { - "$id": "63", + "$id": "72", "name": "getRecursiveModel", "isExactName": false, "resourceName": "SingleDiscriminator", "accessibility": "public", "parameters": [ { - "$id": "64", + "$id": "73", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -954,7 +1061,7 @@ "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.getRecursiveModel.accept", "methodParameterSegments": [ { - "$id": "65", + "$id": "74", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -981,7 +1088,7 @@ 200 ], "bodyType": { - "$ref": "25" + "$ref": "29" }, "headers": [], "isErrorResponse": false, @@ -1007,12 +1114,12 @@ }, "parameters": [ { - "$ref": "65" + "$ref": "74" } ], "response": { "type": { - "$ref": "25" + "$ref": "29" } }, "isOverride": false, @@ -1021,21 +1128,21 @@ "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.getRecursiveModel" }, { - "$id": "66", + "$id": "75", "kind": "basic", "name": "putRecursiveModel", "isExactName": false, "accessibility": "public", "apiVersions": [], "operation": { - "$id": "67", + "$id": "76", "name": "putRecursiveModel", "isExactName": false, "resourceName": "SingleDiscriminator", "accessibility": "public", "parameters": [ { - "$id": "68", + "$id": "77", "kind": "header", "name": "contentType", "serializedName": "Content-Type", @@ -1052,7 +1159,7 @@ "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.putRecursiveModel.contentType", "methodParameterSegments": [ { - "$id": "69", + "$id": "78", "kind": "method", "name": "contentType", "serializedName": "Content-Type", @@ -1074,12 +1181,12 @@ "isExactName": false }, { - "$id": "70", + "$id": "79", "kind": "body", "name": "input", "serializedName": "input", "type": { - "$ref": "25" + "$ref": "29" }, "isApiVersion": false, "contentTypes": [ @@ -1093,12 +1200,12 @@ "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.putRecursiveModel.input", "methodParameterSegments": [ { - "$id": "71", + "$id": "80", "kind": "method", "name": "input", "serializedName": "input", "type": { - "$ref": "25" + "$ref": "29" }, "location": "Body", "isApiVersion": false, @@ -1144,10 +1251,10 @@ }, "parameters": [ { - "$ref": "71" + "$ref": "80" }, { - "$ref": "69" + "$ref": "78" } ], "response": {}, @@ -1157,21 +1264,21 @@ "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.putRecursiveModel" }, { - "$id": "72", + "$id": "81", "kind": "basic", "name": "getMissingDiscriminator", "isExactName": false, "accessibility": "public", "apiVersions": [], "operation": { - "$id": "73", + "$id": "82", "name": "getMissingDiscriminator", "isExactName": false, "resourceName": "SingleDiscriminator", "accessibility": "public", "parameters": [ { - "$id": "74", + "$id": "83", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -1187,7 +1294,7 @@ "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.getMissingDiscriminator.accept", "methodParameterSegments": [ { - "$id": "75", + "$id": "84", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -1214,7 +1321,7 @@ 200 ], "bodyType": { - "$ref": "25" + "$ref": "29" }, "headers": [], "isErrorResponse": false, @@ -1240,12 +1347,12 @@ }, "parameters": [ { - "$ref": "75" + "$ref": "84" } ], "response": { "type": { - "$ref": "25" + "$ref": "29" } }, "isOverride": false, @@ -1254,21 +1361,21 @@ "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.getMissingDiscriminator" }, { - "$id": "76", + "$id": "85", "kind": "basic", "name": "getWrongDiscriminator", "isExactName": false, "accessibility": "public", "apiVersions": [], "operation": { - "$id": "77", + "$id": "86", "name": "getWrongDiscriminator", "isExactName": false, "resourceName": "SingleDiscriminator", "accessibility": "public", "parameters": [ { - "$id": "78", + "$id": "87", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -1284,7 +1391,7 @@ "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.getWrongDiscriminator.accept", "methodParameterSegments": [ { - "$id": "79", + "$id": "88", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -1311,7 +1418,7 @@ 200 ], "bodyType": { - "$ref": "25" + "$ref": "29" }, "headers": [], "isErrorResponse": false, @@ -1337,12 +1444,12 @@ }, "parameters": [ { - "$ref": "79" + "$ref": "88" } ], "response": { "type": { - "$ref": "25" + "$ref": "29" } }, "isOverride": false, @@ -1351,21 +1458,21 @@ "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.getWrongDiscriminator" }, { - "$id": "80", + "$id": "89", "kind": "basic", "name": "getLegacyModel", "isExactName": false, "accessibility": "public", "apiVersions": [], "operation": { - "$id": "81", + "$id": "90", "name": "getLegacyModel", "isExactName": false, "resourceName": "SingleDiscriminator", "accessibility": "public", "parameters": [ { - "$id": "82", + "$id": "91", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -1381,7 +1488,7 @@ "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.getLegacyModel.accept", "methodParameterSegments": [ { - "$id": "83", + "$id": "92", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -1408,7 +1515,7 @@ 200 ], "bodyType": { - "$ref": "44" + "$ref": "48" }, "headers": [], "isErrorResponse": false, @@ -1434,29 +1541,262 @@ }, "parameters": [ { - "$ref": "83" + "$ref": "92" } ], "response": { "type": { - "$ref": "44" + "$ref": "48" } }, "isOverride": false, "generateConvenient": true, "generateProtocol": true, "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.getLegacyModel" + }, + { + "$id": "93", + "kind": "basic", + "name": "getNoSubtypesModel", + "isExactName": false, + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "94", + "name": "getNoSubtypesModel", + "isExactName": false, + "resourceName": "SingleDiscriminator", + "accessibility": "public", + "parameters": [ + { + "$id": "95", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "25" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.getNoSubtypesModel.accept", + "methodParameterSegments": [ + { + "$id": "96", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "25" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.getNoSubtypesModel.accept", + "readOnly": false, + "access": "public", + "decorators": [], + "isExactName": false + } + ], + "isExactName": false + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "55" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ], + "serializationOptions": { + "json": { + "name": "" + } + } + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/type/model/inheritance/single-discriminator/no-subtypes/model", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.getNoSubtypesModel", + "decorators": [], + "namespace": "Type.Model.Inheritance.SingleDiscriminator" + }, + "parameters": [ + { + "$ref": "96" + } + ], + "response": { + "type": { + "$ref": "55" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.getNoSubtypesModel" + }, + { + "$id": "97", + "kind": "basic", + "name": "putNoSubtypesModel", + "isExactName": false, + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "98", + "name": "putNoSubtypesModel", + "isExactName": false, + "resourceName": "SingleDiscriminator", + "accessibility": "public", + "parameters": [ + { + "$id": "99", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "27" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.putNoSubtypesModel.contentType", + "methodParameterSegments": [ + { + "$id": "100", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "27" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.putNoSubtypesModel.contentType", + "readOnly": false, + "access": "public", + "decorators": [], + "isExactName": false + } + ], + "isExactName": false + }, + { + "$id": "101", + "kind": "body", + "name": "input", + "serializedName": "input", + "type": { + "$ref": "55" + }, + "isApiVersion": false, + "contentTypes": [ + "application/json" + ], + "defaultContentType": "application/json", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.putNoSubtypesModel.input", + "methodParameterSegments": [ + { + "$id": "102", + "kind": "method", + "name": "input", + "serializedName": "input", + "type": { + "$ref": "55" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.putNoSubtypesModel.input", + "readOnly": false, + "access": "public", + "decorators": [], + "isExactName": false + } + ], + "isExactName": false, + "serializationOptions": { + "json": { + "name": "input" + } + } + } + ], + "responses": [ + { + "statusCodes": [ + 204 + ], + "headers": [], + "isErrorResponse": false, + "serializationOptions": {} + } + ], + "httpMethod": "PUT", + "uri": "{endpoint}", + "path": "/type/model/inheritance/single-discriminator/no-subtypes/model", + "requestMediaTypes": [ + "application/json" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.putNoSubtypesModel", + "decorators": [], + "namespace": "Type.Model.Inheritance.SingleDiscriminator" + }, + "parameters": [ + { + "$ref": "102" + }, + { + "$ref": "100" + } + ], + "response": {}, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.putNoSubtypesModel" } ], "parameters": [ { - "$id": "84", + "$id": "103", "kind": "endpoint", "name": "endpoint", "serializedName": "endpoint", "doc": "Service host", "type": { - "$id": "85", + "$id": "104", "kind": "url", "name": "endpoint", "crossLanguageDefinitionId": "TypeSpec.url" @@ -1467,7 +1807,7 @@ "isEndpoint": true, "defaultValue": { "type": { - "$id": "86", + "$id": "105", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string" diff --git a/packages/http-client-csharp/package-lock.json b/packages/http-client-csharp/package-lock.json index 5bce2907224..c586240d276 100644 --- a/packages/http-client-csharp/package-lock.json +++ b/packages/http-client-csharp/package-lock.json @@ -12,24 +12,24 @@ "@azure/identity": "^4.13.0" }, "devDependencies": { - "@azure-tools/azure-http-specs": "0.1.0-alpha.40", - "@azure-tools/typespec-azure-core": "0.68.0", - "@azure-tools/typespec-client-generator-core": "0.68.3", + "@azure-tools/azure-http-specs": "0.1.0-alpha.42", + "@azure-tools/typespec-azure-core": "0.69.0", + "@azure-tools/typespec-client-generator-core": "0.69.0", "@microsoft/api-extractor": "^7.52.2", "@types/node": "~22.12.0", - "@typespec/compiler": "1.12.0", - "@typespec/http": "1.12.0", - "@typespec/http-specs": "0.1.0-alpha.37", - "@typespec/json-schema": "1.12.0", - "@typespec/library-linter": "0.82.0", - "@typespec/openapi": "1.12.0", - "@typespec/rest": "0.82.0", + "@typespec/compiler": "1.13.0", + "@typespec/http": "1.13.0", + "@typespec/http-specs": "0.1.0-alpha.38", + "@typespec/json-schema": "1.13.0", + "@typespec/library-linter": "0.83.0", + "@typespec/openapi": "1.13.0", + "@typespec/rest": "0.83.0", "@typespec/spector": "0.1.0-alpha.25", - "@typespec/sse": "0.82.0", - "@typespec/streams": "0.82.0", - "@typespec/tspd": "0.74.2", - "@typespec/versioning": "0.82.0", - "@typespec/xml": "0.82.0", + "@typespec/sse": "0.83.0", + "@typespec/streams": "0.83.0", + "@typespec/tspd": "0.75.0", + "@typespec/versioning": "0.83.0", + "@typespec/xml": "0.83.0", "@vitest/coverage-v8": "^4.1.8", "@vitest/ui": "^4.1.8", "c8": "^10.1.2", @@ -38,15 +38,15 @@ "vitest": "^4.1.8" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": ">=0.68.0 <0.69.0 || ~0.69.0-0", - "@azure-tools/typespec-client-generator-core": ">=0.68.3 <0.69.0 || ~0.69.0-0", - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0", - "@typespec/openapi": "^1.12.0", - "@typespec/rest": ">=0.82.0 <0.83.0 || ~0.83.0-0", - "@typespec/sse": ">=0.82.0 <0.83.0 || ~0.83.0-0", - "@typespec/streams": ">=0.82.0 <0.83.0 || ~0.83.0-0", - "@typespec/versioning": ">=0.82.0 <0.83.0 || ~0.83.0-0" + "@azure-tools/typespec-azure-core": ">=0.69.0 <0.70.0 || ~0.70.0-0", + "@azure-tools/typespec-client-generator-core": ">=0.69.0 <0.70.0 || ~0.70.0-0", + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0", + "@typespec/openapi": "^1.13.0", + "@typespec/rest": ">=0.83.0 <0.84.0 || ~0.84.0-0", + "@typespec/sse": ">=0.83.0 <0.84.0 || ~0.84.0-0", + "@typespec/streams": ">=0.83.0 <0.84.0 || ~0.84.0-0", + "@typespec/versioning": ">=0.83.0 <0.84.0 || ~0.84.0-0" } }, "node_modules/@alloy-js/core": { @@ -90,9 +90,9 @@ } }, "node_modules/@azure-tools/azure-http-specs": { - "version": "0.1.0-alpha.40", - "resolved": "https://registry.npmjs.org/@azure-tools/azure-http-specs/-/azure-http-specs-0.1.0-alpha.40.tgz", - "integrity": "sha512-1WhoWwV+SgpzLUHJdRPo+Ph5mQNe0FtDYHb0dVBhIzRMjWzBvYhdj1iK0yAkwYnm04WxLO5izz5sO6/Lq5KhnQ==", + "version": "0.1.0-alpha.42", + "resolved": "https://registry.npmjs.org/@azure-tools/azure-http-specs/-/azure-http-specs-0.1.0-alpha.42.tgz", + "integrity": "sha512-vQOAepoGK1lSc9ohAub+NM1MiLJS5swIA5Ya3TTIJ4KkD1x6j5msdSRMgNgb0rmux/WWrKTRtsFDAiOF1Z0HKg==", "dev": true, "license": "MIT", "dependencies": { @@ -103,33 +103,33 @@ "node": ">=22.0.0" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": "^0.68.0", - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0", - "@typespec/rest": "^0.82.0", - "@typespec/versioning": "^0.82.0", - "@typespec/xml": "^0.82.0" + "@azure-tools/typespec-azure-core": "^0.69.0", + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0", + "@typespec/rest": "^0.83.0", + "@typespec/versioning": "^0.83.0", + "@typespec/xml": "^0.83.0" } }, "node_modules/@azure-tools/typespec-azure-core": { - "version": "0.68.0", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-core/-/typespec-azure-core-0.68.0.tgz", - "integrity": "sha512-p0qUkRZav5fdQvGe2gSCvlgsvpM0y9xVhgH2GpXi5ZzpYfNGzxd8oZr8VOCP8mjMVfGQ3AtnowbmrHALEZgz7Q==", + "version": "0.69.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-core/-/typespec-azure-core-0.69.0.tgz", + "integrity": "sha512-UNdPb/DgMvXqwWk9hb54QOAumCJ6u6GGy+bj3RIIT1Sht6FR9rIn8AQ/UQ7WtrhbJBoqvQo5dxtS565a9/VRZw==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0", - "@typespec/rest": "^0.82.0" + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0", + "@typespec/rest": "^0.83.0" } }, "node_modules/@azure-tools/typespec-client-generator-core": { - "version": "0.68.3", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-client-generator-core/-/typespec-client-generator-core-0.68.3.tgz", - "integrity": "sha512-+OdRM36SJYZRZl8wrtLzkS6KfK5C2Y+V6NpSJxyZALp4PZghCaCHhage94DavgfjcODG+PMPoLEP4uFomMlQyw==", + "version": "0.69.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-client-generator-core/-/typespec-client-generator-core-0.69.0.tgz", + "integrity": "sha512-ro8zzOeiN/74r0wM19R77gzLtbfjIFgKgr1Rusii/vhCfJIoVC7IcqLxhbJl0RVkjyhRFKt4GCRAw4iurnrDnw==", "dev": true, "license": "MIT", "dependencies": { @@ -141,16 +141,16 @@ "node": ">=22.0.0" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": "^0.68.0", - "@typespec/compiler": "^1.12.0", - "@typespec/events": "^0.82.0", - "@typespec/http": "^1.12.0", - "@typespec/openapi": "^1.12.0", - "@typespec/rest": "^0.82.0", - "@typespec/sse": "^0.82.0", - "@typespec/streams": "^0.82.0", - "@typespec/versioning": "^0.82.0", - "@typespec/xml": "^0.82.0" + "@azure-tools/typespec-azure-core": "^0.69.0", + "@typespec/compiler": "^1.13.0", + "@typespec/events": "^0.83.0", + "@typespec/http": "^1.13.0", + "@typespec/openapi": "^1.13.0", + "@typespec/rest": "^0.83.0", + "@typespec/sse": "^0.83.0", + "@typespec/streams": "^0.83.0", + "@typespec/versioning": "^0.83.0", + "@typespec/xml": "^0.83.0" } }, "node_modules/@azure/abort-controller": { @@ -1668,9 +1668,9 @@ } }, "node_modules/@typespec/compiler": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/@typespec/compiler/-/compiler-1.12.0.tgz", - "integrity": "sha512-hKCkHEEDdCpXFyOU8ln+TzBBwonFMbkeUV0zIc+vBETyO8p/Upui3XvEyLOyB4CpKUReHzGeGm3gcFjNc73ygg==", + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/@typespec/compiler/-/compiler-1.13.0.tgz", + "integrity": "sha512-DonoHiyAMx0UjSmssqTrFtya+v97wny1aHcTLU5QF2wFzLATtcwUU9hbPC+eXhepuTunMOCHf8yk3pEsH6PZYA==", "dev": true, "license": "MIT", "dependencies": { @@ -1700,9 +1700,9 @@ } }, "node_modules/@typespec/events": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/events/-/events-0.82.0.tgz", - "integrity": "sha512-4gxwWndMVmYF6e5ETrwW6b77h1DsSc2ZiIbNo98XePaynD6yz/ooHKKtNKacjC2gmWhfRz1ArPioYn0YHvQkxw==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/events/-/events-0.83.0.tgz", + "integrity": "sha512-3EP1EIjdLgwStgd2rGWaF/QqY7YRAt+DIYnnYG2VsdPwa8s2t6K6eJ9YJDXveeHImAkHs+cpFuwxnjKMl4hOyw==", "dev": true, "license": "MIT", "peer": true, @@ -1710,21 +1710,21 @@ "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0" + "@typespec/compiler": "^1.13.0" } }, "node_modules/@typespec/http": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/@typespec/http/-/http-1.12.0.tgz", - "integrity": "sha512-3Bb1M6VSuEVPWOecXj3h3I/ddMpb9cmKRQQq34oq7LatiK4fwVBp+EdWbqzEzaRUGHm9mZtqsMsxZf5FndT8dg==", + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/@typespec/http/-/http-1.13.0.tgz", + "integrity": "sha512-tf8XFddU6g1MZSAVCLC/0Xa4fNfUO0CcHe6PWpmC3bvUojxMnpRcERI2DdoRJ+aycB9Q+Z8wN8bJO3up6u+sCw==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0", - "@typespec/streams": "^0.82.0" + "@typespec/compiler": "^1.13.0", + "@typespec/streams": "^0.83.0" }, "peerDependenciesMeta": { "@typespec/streams": { @@ -1733,9 +1733,9 @@ } }, "node_modules/@typespec/http-specs": { - "version": "0.1.0-alpha.37", - "resolved": "https://registry.npmjs.org/@typespec/http-specs/-/http-specs-0.1.0-alpha.37.tgz", - "integrity": "sha512-XOIr51yuGVGMjr83OlpaeXWv2CSV+nnFZl8+Evws/M3DZfpQhMmbl7bSVYu378kCjFCw2JNLlob9e3fzJxaNdg==", + "version": "0.1.0-alpha.38", + "resolved": "https://registry.npmjs.org/@typespec/http-specs/-/http-specs-0.1.0-alpha.38.tgz", + "integrity": "sha512-/DlR8P93iFhULlLYDUy+aSkOW2udDrHdIfdIHko8aFnmfC5QGXE2fcFphtNlJHCQEYTdZwfAxmBu/TsEygR8jw==", "dev": true, "license": "MIT", "dependencies": { @@ -1746,17 +1746,17 @@ "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0", - "@typespec/rest": "^0.82.0", - "@typespec/versioning": "^0.82.0", - "@typespec/xml": "^0.82.0" + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0", + "@typespec/rest": "^0.83.0", + "@typespec/versioning": "^0.83.0", + "@typespec/xml": "^0.83.0" } }, "node_modules/@typespec/json-schema": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/@typespec/json-schema/-/json-schema-1.12.0.tgz", - "integrity": "sha512-e/hxD6q0ThpCmIXOt4wseC30dv1lWnmQJaDhsn6MJySNVpcfTw9xVgj40Oeygc3TC1nO5X0cICtkOqDV/FMFAw==", + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/@typespec/json-schema/-/json-schema-1.13.0.tgz", + "integrity": "sha512-o5yxs4aGhfFTkVNAkpFlO3LP2O8kWHQUgBzZ0s6tcbFlElGH86jUsdesT8O5ijoA0Cpa//m39wwxIcmBB2DiiA==", "dev": true, "license": "MIT", "dependencies": { @@ -1767,48 +1767,48 @@ "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0" + "@typespec/compiler": "^1.13.0" } }, "node_modules/@typespec/library-linter": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/library-linter/-/library-linter-0.82.0.tgz", - "integrity": "sha512-sNTE+dzaoMxZMdCoUJ7L4kyBHeJUbNBDS5PY+ZyFdA9EOa3fzzd5v3dRFmlMWzvow10oAKH1tHh/c6AhFbIl5Q==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/library-linter/-/library-linter-0.83.0.tgz", + "integrity": "sha512-pivCXKxVUEM/1PHAVOTy4NpTUTg2AikSeXN5R3HeHhkboHS203sSdsussKgvKHi2QbsaCYt2srTN29/fo+HcyQ==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0" + "@typespec/compiler": "^1.13.0" } }, "node_modules/@typespec/openapi": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/@typespec/openapi/-/openapi-1.12.0.tgz", - "integrity": "sha512-XtkCMPpzXFfuIzmx/BQrCMUCCk7d37lkqZe5ubJmvJ02Fr7yvAbofrgtNUZ1BbFe3TBBUS2nB3E3mjT3tE4zCQ==", + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/@typespec/openapi/-/openapi-1.13.0.tgz", + "integrity": "sha512-omPc9n+LM2WvjYwnIf31RCxmG17fFUOVLBRsWg4T1mbcsNCj4grnNP7Lwt+irIZCiKtmLKxq3ViE7jYixCkZ3g==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0" + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0" } }, "node_modules/@typespec/rest": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/rest/-/rest-0.82.0.tgz", - "integrity": "sha512-cKjKEd8lgE3EdU9b5xXLoSdKBcifITOhHS2n9LPbEG9w6APfWDWGdtUe4UKV3wxWq9HlT143wpECW7IjrPhjnA==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/rest/-/rest-0.83.0.tgz", + "integrity": "sha512-WMEwEe1kdaOdZ0c+ct5BVmTSBXkrPniUYDWCz3K52T4in2dNc7J6YGP6tL8bXgQz5B0CsP0VNO12N+UysQDsLw==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0" + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0" } }, "node_modules/@typespec/spec-api": { @@ -1939,32 +1939,32 @@ } }, "node_modules/@typespec/sse": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/sse/-/sse-0.82.0.tgz", - "integrity": "sha512-4jBByfLsS7yQAIqmbLkfrw4XoPm9kOqawvW5gVXmKtnMMDYR0RmfBhsnAXBqhUXGbnFq0bDJGEw3GX+6k3mKnA==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/sse/-/sse-0.83.0.tgz", + "integrity": "sha512-04WNaju2rwBbcF5pG+HrKQtdcrmSGuTVziLHNA9XOqj1qM7Uon3+wo2g+ZZ3Z6tngfqQoTCPyDcRHqZtGRdNuw==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0", - "@typespec/events": "^0.82.0", - "@typespec/http": "^1.12.0", - "@typespec/streams": "^0.82.0" + "@typespec/compiler": "^1.13.0", + "@typespec/events": "^0.83.0", + "@typespec/http": "^1.13.0", + "@typespec/streams": "^0.83.0" } }, "node_modules/@typespec/streams": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/streams/-/streams-0.82.0.tgz", - "integrity": "sha512-cr/6h6VV/6OJeG8RNcSd0SDes5iEXiuGUcKGrMN6wF8qKTTrY2hXNhfqCCn3lamDOg00wbi7ke+laz6pHWN3tg==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/streams/-/streams-0.83.0.tgz", + "integrity": "sha512-wbO6sdH1Uf+UwjxxsWdHQkjJ3wwiYsAKI+L66qnDYVXAFe02sUdMKd0mxH5o9ipGXE52MZ+yvZ52vHAD+g3RFQ==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0" + "@typespec/compiler": "^1.13.0" } }, "node_modules/@typespec/ts-http-runtime": { @@ -1982,9 +1982,9 @@ } }, "node_modules/@typespec/tspd": { - "version": "0.74.2", - "resolved": "https://registry.npmjs.org/@typespec/tspd/-/tspd-0.74.2.tgz", - "integrity": "sha512-R7JK1H7xD/1dced4GKpbiMn/r7f1xwNMbIT9o2+XlohUCyA+MPnGvy8KVUYmv16ZUKwI9V6/RDysOFSgqdg07w==", + "version": "0.75.0", + "resolved": "https://registry.npmjs.org/@typespec/tspd/-/tspd-0.75.0.tgz", + "integrity": "sha512-lGCpN5aM1O8utVH+6c7UMv9IZtEKlxc4O5blxp06TdnYWjOxyOEm+R9BBzaY7aq6Jtj/YamdDnMvzV42y/F10Q==", "dev": true, "license": "MIT", "dependencies": { @@ -1995,7 +1995,7 @@ "@microsoft/api-extractor-model": "^7.33.5", "@microsoft/tsdoc": "^0.16.0", "@microsoft/tsdoc-config": "^0.18.1", - "@typespec/compiler": "^1.12.0", + "@typespec/compiler": "^1.13.0", "picocolors": "^1.1.1", "prettier": "^3.8.1", "typedoc": "^0.28.19", @@ -2011,29 +2011,29 @@ } }, "node_modules/@typespec/versioning": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/versioning/-/versioning-0.82.0.tgz", - "integrity": "sha512-s8giuYQTQPniy2YxNfKXYpAU2Vm4L74TdOsbFWe0tG+jnOy/9tt7kKTH4QF1sB8nRvmjv8h31EoHtZYOPe1GvA==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/versioning/-/versioning-0.83.0.tgz", + "integrity": "sha512-nE66ta0ixpHB6FQpSzqnj8QnVfgFsxeK/4Xv+DxYx2nB/w18f6VjkF+hW+A/zs1tZIYvBZVbCNa/Rcr8zM6fhg==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0" + "@typespec/compiler": "^1.13.0" } }, "node_modules/@typespec/xml": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/xml/-/xml-0.82.0.tgz", - "integrity": "sha512-/Bwlt7HwSltojSbalkh7hGRh/lB5aMJllnb7gAAf3xRPMlnmu5VJqDFFcbZKqDvkwgGXZX/xHo458c4kott5Ug==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/xml/-/xml-0.83.0.tgz", + "integrity": "sha512-2/dtAD8jGPkIdwpQ1G1P+5+qdMPeafQiIKCd8NdAnOo0w9OZ59Io52jINm9HdN8+FcbOrqK8+B2N9rlPRj7PqA==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0" + "@typespec/compiler": "^1.13.0" } }, "node_modules/@vitest/coverage-v8": { diff --git a/packages/http-client-csharp/package.json b/packages/http-client-csharp/package.json index f91b1e27035..f90454931af 100644 --- a/packages/http-client-csharp/package.json +++ b/packages/http-client-csharp/package.json @@ -58,35 +58,35 @@ "emitter/lib/*.tsp" ], "peerDependencies": { - "@azure-tools/typespec-azure-core": ">=0.68.0 <0.69.0 || ~0.69.0-0", - "@azure-tools/typespec-client-generator-core": ">=0.68.3 <0.69.0 || ~0.69.0-0", - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0", - "@typespec/openapi": "^1.12.0", - "@typespec/rest": ">=0.82.0 <0.83.0 || ~0.83.0-0", - "@typespec/sse": ">=0.82.0 <0.83.0 || ~0.83.0-0", - "@typespec/streams": ">=0.82.0 <0.83.0 || ~0.83.0-0", - "@typespec/versioning": ">=0.82.0 <0.83.0 || ~0.83.0-0" + "@azure-tools/typespec-azure-core": ">=0.69.0 <0.70.0 || ~0.70.0-0", + "@azure-tools/typespec-client-generator-core": ">=0.69.0 <0.70.0 || ~0.70.0-0", + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0", + "@typespec/openapi": "^1.13.0", + "@typespec/rest": ">=0.83.0 <0.84.0 || ~0.84.0-0", + "@typespec/sse": ">=0.83.0 <0.84.0 || ~0.84.0-0", + "@typespec/streams": ">=0.83.0 <0.84.0 || ~0.84.0-0", + "@typespec/versioning": ">=0.83.0 <0.84.0 || ~0.84.0-0" }, "devDependencies": { - "@azure-tools/azure-http-specs": "0.1.0-alpha.40", - "@azure-tools/typespec-azure-core": "0.68.0", - "@azure-tools/typespec-client-generator-core": "0.68.3", + "@azure-tools/azure-http-specs": "0.1.0-alpha.42", + "@azure-tools/typespec-azure-core": "0.69.0", + "@azure-tools/typespec-client-generator-core": "0.69.0", "@microsoft/api-extractor": "^7.52.2", "@types/node": "~22.12.0", - "@typespec/compiler": "1.12.0", - "@typespec/http": "1.12.0", - "@typespec/http-specs": "0.1.0-alpha.37", - "@typespec/json-schema": "1.12.0", - "@typespec/library-linter": "0.82.0", - "@typespec/openapi": "1.12.0", - "@typespec/rest": "0.82.0", + "@typespec/compiler": "1.13.0", + "@typespec/http": "1.13.0", + "@typespec/http-specs": "0.1.0-alpha.38", + "@typespec/json-schema": "1.13.0", + "@typespec/library-linter": "0.83.0", + "@typespec/openapi": "1.13.0", + "@typespec/rest": "0.83.0", "@typespec/spector": "0.1.0-alpha.25", - "@typespec/sse": "0.82.0", - "@typespec/streams": "0.82.0", - "@typespec/tspd": "0.74.2", - "@typespec/versioning": "0.82.0", - "@typespec/xml": "0.82.0", + "@typespec/sse": "0.83.0", + "@typespec/streams": "0.83.0", + "@typespec/tspd": "0.75.0", + "@typespec/versioning": "0.83.0", + "@typespec/xml": "0.83.0", "@vitest/coverage-v8": "^4.1.8", "@vitest/ui": "^4.1.8", "c8": "^10.1.2", diff --git a/packages/http-client-csharp/readme.md b/packages/http-client-csharp/readme.md index 2acc3d7cbaf..ea48d690c25 100644 --- a/packages/http-client-csharp/readme.md +++ b/packages/http-client-csharp/readme.md @@ -113,6 +113,12 @@ Set the log level for which to collect traces. The default value is `info`. Set to `true` to disable XML documentation generation. The default value is `false`. +### `disable-roslyn-reduce` + +**Type:** `boolean` + +Set to `true` to skip the Roslyn reduce (simplification) post-processing step. This speeds up generation and is useful when iterating quickly. The default value is `false`. + ### `generator-name` **Type:** `string` @@ -127,16 +133,35 @@ Allows emitter authors to specify the path to a custom emitter package, allowing ### `plugins` -**Type:** `array` +**Type:** `string[]` + +Paths to generator plugin assemblies (DLLs) or directories containing plugin assemblies. Each plugin must contain a class that extends `GeneratorPlugin`. Paths may be absolute or relative to the resolved `emitter-output-dir`. For example, to load plugins that live in a `codegen` folder under the output directory: -Paths to generator plugin assemblies (DLLs) or directories containing plugin assemblies. Each plugin must contain a class that extends GeneratorPlugin. +```yaml +options: + "@typespec/http-client-csharp": + plugins: + - "codegen/MyPlugin.dll" # file relative to emitter-output-dir + - "codegen" # directory containing plugin assemblies + - "/abs/path/to/MyPlugin.dll" # absolute path used as-is +``` ### `license` -**Type:** `object` +**Type:** `object { name, company, link, header, description }` License information for the generated client code. +**Properties:** + +| Name | Type | Default | Description | +| ------------- | -------- | ------- | ----------- | +| `name` | `string` | | | +| `company` | `string` | | | +| `link` | `string` | | | +| `header` | `string` | | | +| `description` | `string` | | | + ### `sdk-context-options` **Type:** `object` diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/package.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/package.json index 2a35b90075a..782e18e5756 100644 --- a/packages/http-client-java/generator/http-client-generator-clientcore-test/package.json +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/package.json @@ -14,25 +14,25 @@ "dependencies": { "@typespec/spector": "0.1.0-alpha.25", "@typespec/spec-api": "0.1.0-alpha.14", - "@typespec/http-specs": "0.1.0-alpha.37", - "@typespec/json-schema": "1.12.0", - "@typespec/http-client-java": "file:../../typespec-http-client-java-0.8.1.tgz", + "@typespec/http-specs": "0.1.0-alpha.38", + "@typespec/json-schema": "1.13.0", + "@typespec/http-client-java": "file:../../typespec-http-client-java-0.9.0.tgz", "@typespec/http-client-java-tests": "file:" }, "overrides": { - "@typespec/compiler": "1.12.0", - "@typespec/http": "1.12.0", - "@typespec/rest": "0.82.0", - "@typespec/versioning": "0.82.0", - "@typespec/openapi": "1.12.0", - "@typespec/xml": "0.82.0", - "@typespec/events": "0.82.0", - "@typespec/sse": "0.82.0", - "@typespec/streams": "0.82.0", - "@azure-tools/typespec-azure-core": "0.68.0", - "@azure-tools/typespec-client-generator-core": "0.68.4", - "@azure-tools/typespec-azure-resource-manager": "0.68.0", - "@azure-tools/typespec-autorest": "0.68.0" + "@typespec/compiler": "1.13.0", + "@typespec/http": "1.13.0", + "@typespec/rest": "0.83.0", + "@typespec/versioning": "0.83.0", + "@typespec/openapi": "1.13.0", + "@typespec/xml": "0.83.0", + "@typespec/events": "0.83.0", + "@typespec/sse": "0.83.0", + "@typespec/streams": "0.83.0", + "@azure-tools/typespec-azure-core": "0.69.0", + "@azure-tools/typespec-client-generator-core": "0.69.0", + "@azure-tools/typespec-azure-resource-manager": "0.69.0", + "@azure-tools/typespec-autorest": "0.69.0" }, "private": true } diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/BodyRootClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/BodyRootClient.java new file mode 100644 index 00000000000..085d6d8f135 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/BodyRootClient.java @@ -0,0 +1,66 @@ +package parameters.bodyroot; + +import io.clientcore.core.annotations.Metadata; +import io.clientcore.core.annotations.MetadataProperties; +import io.clientcore.core.annotations.ReturnType; +import io.clientcore.core.annotations.ServiceClient; +import io.clientcore.core.annotations.ServiceMethod; +import io.clientcore.core.http.models.HttpResponseException; +import io.clientcore.core.http.models.RequestContext; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.instrumentation.Instrumentation; +import parameters.bodyroot.implementation.BodyRootClientImpl; + +/** + * Initializes a new instance of the synchronous BodyRootClient type. + */ +@ServiceClient(builder = BodyRootClientBuilder.class) +public final class BodyRootClient { + @Metadata(properties = { MetadataProperties.GENERATED }) + private final BodyRootClientImpl serviceClient; + + private final Instrumentation instrumentation; + + /** + * Initializes an instance of BodyRootClient class. + * + * @param serviceClient the service client implementation. + * @param instrumentation the instrumentation instance. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + BodyRootClient(BodyRootClientImpl serviceClient, Instrumentation instrumentation) { + this.serviceClient = serviceClient; + this.instrumentation = instrumentation; + } + + /** + * The nested operation. + * + * @param bodyRootParameters The bodyRootParameters parameter. + * @param requestContext The context to configure the HTTP request before HTTP client sends it. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @ServiceMethod(returns = ReturnType.SINGLE) + public Response nestedWithResponse(BodyRootModel bodyRootParameters, RequestContext requestContext) { + return this.instrumentation.instrumentWithResponse("Parameters.BodyRoot.nested", requestContext, + updatedContext -> this.serviceClient.nestedWithResponse(bodyRootParameters, updatedContext)); + } + + /** + * The nested operation. + * + * @param bodyRootParameters The bodyRootParameters parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @ServiceMethod(returns = ReturnType.SINGLE) + public void nested(BodyRootModel bodyRootParameters) { + nestedWithResponse(bodyRootParameters, RequestContext.none()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/BodyRootClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/BodyRootClientBuilder.java new file mode 100644 index 00000000000..649503e296a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/BodyRootClientBuilder.java @@ -0,0 +1,235 @@ +package parameters.bodyroot; + +import io.clientcore.core.annotations.Metadata; +import io.clientcore.core.annotations.MetadataProperties; +import io.clientcore.core.annotations.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpInstrumentationOptions; +import io.clientcore.core.http.pipeline.HttpInstrumentationPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectOptions; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryOptions; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.instrumentation.Instrumentation; +import io.clientcore.core.instrumentation.SdkInstrumentationOptions; +import io.clientcore.core.traits.ConfigurationTrait; +import io.clientcore.core.traits.EndpointTrait; +import io.clientcore.core.traits.HttpTrait; +import io.clientcore.core.traits.ProxyTrait; +import io.clientcore.core.utils.CoreUtils; +import io.clientcore.core.utils.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import parameters.bodyroot.implementation.BodyRootClientImpl; + +/** + * A builder for creating a new instance of the BodyRootClient type. + */ +@ServiceClientBuilder(serviceClients = { BodyRootClient.class }) +public final class BodyRootClientBuilder implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(properties = { MetadataProperties.GENERATED }) + private static final String SDK_NAME = "name"; + + @Metadata(properties = { MetadataProperties.GENERATED }) + private static final String SDK_VERSION = "version"; + + @Metadata(properties = { MetadataProperties.GENERATED }) + private static final Map PROPERTIES = CoreUtils.getProperties("parameters-bodyroot.properties"); + + @Metadata(properties = { MetadataProperties.GENERATED }) + private final List pipelinePolicies; + + /** + * Create an instance of the BodyRootClientBuilder. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + public BodyRootClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @Override + public BodyRootClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @Override + public BodyRootClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @Override + public BodyRootClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @Override + public BodyRootClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The instrumentation configuration for HTTP requests and responses. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + private HttpInstrumentationOptions httpInstrumentationOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @Override + public BodyRootClientBuilder httpInstrumentationOptions(HttpInstrumentationOptions httpInstrumentationOptions) { + this.httpInstrumentationOptions = httpInstrumentationOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @Override + public BodyRootClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @Override + public BodyRootClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @Override + public BodyRootClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of BodyRootClientImpl with the provided parameters. + * + * @return an instance of BodyRootClientImpl. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + private BodyRootClientImpl buildInnerClient() { + this.validateClient(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + HttpInstrumentationOptions localHttpInstrumentationOptions = this.httpInstrumentationOptions == null + ? new HttpInstrumentationOptions() + : this.httpInstrumentationOptions; + SdkInstrumentationOptions sdkInstrumentationOptions + = new SdkInstrumentationOptions(PROPERTIES.getOrDefault(SDK_NAME, "UnknownName")) + .setSdkVersion(PROPERTIES.get(SDK_VERSION)) + .setEndpoint(localEndpoint); + Instrumentation instrumentation + = Instrumentation.create(localHttpInstrumentationOptions, sdkInstrumentationOptions); + BodyRootClientImpl client = new BodyRootClientImpl(createHttpPipeline(), instrumentation, localEndpoint); + return client; + } + + @Metadata(properties = { MetadataProperties.GENERATED }) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(properties = { MetadataProperties.GENERATED }) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpInstrumentationOptions localHttpInstrumentationOptions = this.httpInstrumentationOptions == null + ? new HttpInstrumentationOptions() + : this.httpInstrumentationOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpInstrumentationPolicy(localHttpInstrumentationOptions)); + policies.forEach(httpPipelineBuilder::addPolicy); + return httpPipelineBuilder.httpClient(httpClient).build(); + } + + /** + * Builds an instance of BodyRootClient class. + * + * @return an instance of BodyRootClient. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + public BodyRootClient buildClient() { + BodyRootClientImpl innerClient = buildInnerClient(); + return new BodyRootClient(innerClient, innerClient.getInstrumentation()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/BodyRootModel.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/BodyRootModel.java new file mode 100644 index 00000000000..e37cce00e86 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/BodyRootModel.java @@ -0,0 +1,150 @@ +package parameters.bodyroot; + +import io.clientcore.core.annotations.Metadata; +import io.clientcore.core.annotations.MetadataProperties; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The BodyRootModel model. + */ +@Metadata(properties = { MetadataProperties.FLUENT }) +public final class BodyRootModel implements JsonSerializable { + /* + * The category property. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + private String category; + + /* + * The linkType property. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + private String linkType; + + /* + * The wasSuccessful property. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + private Boolean wasSuccessful; + + /** + * Creates an instance of BodyRootModel class. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + public BodyRootModel() { + } + + /** + * Get the category property: The category property. + * + * @return the category value. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + public String getCategory() { + return this.category; + } + + /** + * Set the category property: The category property. + * + * @param category the category value to set. + * @return the BodyRootModel object itself. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + public BodyRootModel setCategory(String category) { + this.category = category; + return this; + } + + /** + * Get the linkType property: The linkType property. + * + * @return the linkType value. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + public String getLinkType() { + return this.linkType; + } + + /** + * Set the linkType property: The linkType property. + * + * @param linkType the linkType value to set. + * @return the BodyRootModel object itself. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + public BodyRootModel setLinkType(String linkType) { + this.linkType = linkType; + return this; + } + + /** + * Get the wasSuccessful property: The wasSuccessful property. + * + * @return the wasSuccessful value. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + public Boolean isWasSuccessful() { + return this.wasSuccessful; + } + + /** + * Set the wasSuccessful property: The wasSuccessful property. + * + * @param wasSuccessful the wasSuccessful value to set. + * @return the BodyRootModel object itself. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + public BodyRootModel setWasSuccessful(Boolean wasSuccessful) { + this.wasSuccessful = wasSuccessful; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("category", this.category); + jsonWriter.writeStringField("linkType", this.linkType); + jsonWriter.writeBooleanField("wasSuccessful", this.wasSuccessful); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BodyRootModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BodyRootModel if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the BodyRootModel. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + public static BodyRootModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BodyRootModel deserializedBodyRootModel = new BodyRootModel(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("category".equals(fieldName)) { + deserializedBodyRootModel.category = reader.getString(); + } else if ("linkType".equals(fieldName)) { + deserializedBodyRootModel.linkType = reader.getString(); + } else if ("wasSuccessful".equals(fieldName)) { + deserializedBodyRootModel.wasSuccessful = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } + + return deserializedBodyRootModel; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/implementation/BodyRootClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/implementation/BodyRootClientImpl.java new file mode 100644 index 00000000000..51f1961f020 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/implementation/BodyRootClientImpl.java @@ -0,0 +1,129 @@ +package parameters.bodyroot.implementation; + +import io.clientcore.core.annotations.ReturnType; +import io.clientcore.core.annotations.ServiceInterface; +import io.clientcore.core.annotations.ServiceMethod; +import io.clientcore.core.http.annotations.BodyParam; +import io.clientcore.core.http.annotations.HeaderParam; +import io.clientcore.core.http.annotations.HostParam; +import io.clientcore.core.http.annotations.HttpRequestInformation; +import io.clientcore.core.http.annotations.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.HttpResponseException; +import io.clientcore.core.http.models.RequestContext; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.instrumentation.Instrumentation; +import java.lang.reflect.InvocationTargetException; +import parameters.bodyroot.BodyRootModel; + +/** + * Initializes a new instance of the BodyRootClient type. + */ +public final class BodyRootClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BodyRootClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * The HTTP pipeline to send requests through. + */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** + * The instance of instrumentation to report telemetry. + */ + private final Instrumentation instrumentation; + + /** + * Gets The instance of instrumentation to report telemetry. + * + * @return the instrumentation value. + */ + public Instrumentation getInstrumentation() { + return this.instrumentation; + } + + /** + * Initializes an instance of BodyRootClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param instrumentation The instance of instrumentation to report telemetry. + * @param endpoint Service host. + */ + public BodyRootClientImpl(HttpPipeline httpPipeline, Instrumentation instrumentation, String endpoint) { + this.httpPipeline = httpPipeline; + this.instrumentation = instrumentation; + this.endpoint = endpoint; + this.service = BodyRootClientService.getNewInstance(this.httpPipeline); + } + + /** + * The interface defining all the services for BodyRootClient to be used by the proxy service to perform REST calls. + */ + @ServiceInterface(name = "BodyRootClient", host = "{endpoint}") + public interface BodyRootClientService { + static BodyRootClientService getNewInstance(HttpPipeline pipeline) { + try { + Class clazz = Class.forName("parameters.bodyroot.implementation.BodyRootClientServiceImpl"); + return (BodyRootClientService) clazz.getMethod("getNewInstance", HttpPipeline.class) + .invoke(null, pipeline); + } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException + | InvocationTargetException e) { + throw new RuntimeException(e); + } + + } + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/parameters/body-root/nested", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response nested(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BodyRootModel bodyRootParameters, RequestContext requestContext); + } + + /** + * The nested operation. + * + * @param bodyRootParameters The bodyRootParameters parameter. + * @param requestContext The context to configure the HTTP request before HTTP client sends it. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response nestedWithResponse(BodyRootModel bodyRootParameters, RequestContext requestContext) { + return this.instrumentation.instrumentWithResponse("Parameters.BodyRoot.nested", requestContext, + updatedContext -> { + final String contentType = "application/json"; + return service.nested(this.getEndpoint(), contentType, bodyRootParameters, updatedContext); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/implementation/package-info.java new file mode 100644 index 00000000000..970e0838ae1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/implementation/package-info.java @@ -0,0 +1,5 @@ +/** + * Package containing the implementations for BodyRoot. + * Test for @bodyRoot parameter patterns. + */ +package parameters.bodyroot.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/package-info.java new file mode 100644 index 00000000000..5130971aeac --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/package-info.java @@ -0,0 +1,5 @@ +/** + * Package containing the classes for BodyRoot. + * Test for @bodyRoot parameter patterns. + */ +package parameters.bodyroot; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/QueryClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/ConstantClient.java similarity index 93% rename from packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/QueryClient.java rename to packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/ConstantClient.java index 6941ae352f6..0f7e7d4c32c 100644 --- a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/QueryClient.java +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/ConstantClient.java @@ -15,20 +15,20 @@ * Initializes a new instance of the synchronous QueryClient type. */ @ServiceClient(builder = QueryClientBuilder.class) -public final class QueryClient { +public final class ConstantClient { @Metadata(properties = { MetadataProperties.GENERATED }) private final ConstantsImpl serviceClient; private final Instrumentation instrumentation; /** - * Initializes an instance of QueryClient class. + * Initializes an instance of ConstantClient class. * * @param serviceClient the service client implementation. * @param instrumentation the instrumentation instance. */ @Metadata(properties = { MetadataProperties.GENERATED }) - QueryClient(ConstantsImpl serviceClient, Instrumentation instrumentation) { + ConstantClient(ConstantsImpl serviceClient, Instrumentation instrumentation) { this.serviceClient = serviceClient; this.instrumentation = instrumentation; } diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/QueryClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/QueryClientBuilder.java index 4bb9b538c9f..19f12b62b87 100644 --- a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/QueryClientBuilder.java +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/QueryClientBuilder.java @@ -31,7 +31,7 @@ /** * A builder for creating a new instance of the QueryClient type. */ -@ServiceClientBuilder(serviceClients = { QueryClient.class }) +@ServiceClientBuilder(serviceClients = { ConstantClient.class, SpecialCharClient.class }) public final class QueryClientBuilder implements HttpTrait, ProxyTrait, ConfigurationTrait, EndpointTrait { @Metadata(properties = { MetadataProperties.GENERATED }) @@ -223,13 +223,24 @@ private HttpPipeline createHttpPipeline() { } /** - * Builds an instance of QueryClient class. + * Builds an instance of ConstantClient class. * - * @return an instance of QueryClient. + * @return an instance of ConstantClient. */ @Metadata(properties = { MetadataProperties.GENERATED }) - public QueryClient buildQueryClient() { + public ConstantClient buildConstantClient() { QueryClientImpl innerClient = buildInnerClient(); - return new QueryClient(innerClient.getConstants(), innerClient.getInstrumentation()); + return new ConstantClient(innerClient.getConstants(), innerClient.getInstrumentation()); + } + + /** + * Builds an instance of SpecialCharClient class. + * + * @return an instance of SpecialCharClient. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + public SpecialCharClient buildSpecialCharClient() { + QueryClientImpl innerClient = buildInnerClient(); + return new SpecialCharClient(innerClient.getSpecialChars(), innerClient.getInstrumentation()); } } diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/SpecialCharClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/SpecialCharClient.java new file mode 100644 index 00000000000..453716449f0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/SpecialCharClient.java @@ -0,0 +1,66 @@ +package parameters.query; + +import io.clientcore.core.annotations.Metadata; +import io.clientcore.core.annotations.MetadataProperties; +import io.clientcore.core.annotations.ReturnType; +import io.clientcore.core.annotations.ServiceClient; +import io.clientcore.core.annotations.ServiceMethod; +import io.clientcore.core.http.models.HttpResponseException; +import io.clientcore.core.http.models.RequestContext; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.instrumentation.Instrumentation; +import parameters.query.implementation.SpecialCharsImpl; + +/** + * Initializes a new instance of the synchronous QueryClient type. + */ +@ServiceClient(builder = QueryClientBuilder.class) +public final class SpecialCharClient { + @Metadata(properties = { MetadataProperties.GENERATED }) + private final SpecialCharsImpl serviceClient; + + private final Instrumentation instrumentation; + + /** + * Initializes an instance of SpecialCharClient class. + * + * @param serviceClient the service client implementation. + * @param instrumentation the instrumentation instance. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + SpecialCharClient(SpecialCharsImpl serviceClient, Instrumentation instrumentation) { + this.serviceClient = serviceClient; + this.instrumentation = instrumentation; + } + + /** + * The dollarSign operation. + * + * @param filter The filter parameter. + * @param requestContext The context to configure the HTTP request before HTTP client sends it. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @ServiceMethod(returns = ReturnType.SINGLE) + public Response dollarSignWithResponse(String filter, RequestContext requestContext) { + return this.instrumentation.instrumentWithResponse("Parameters.Query.SpecialChar.dollarSign", requestContext, + updatedContext -> this.serviceClient.dollarSignWithResponse(filter, updatedContext)); + } + + /** + * The dollarSign operation. + * + * @param filter The filter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @ServiceMethod(returns = ReturnType.SINGLE) + public void dollarSign(String filter) { + dollarSignWithResponse(filter, RequestContext.none()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/implementation/QueryClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/implementation/QueryClientImpl.java index 77bdb99a195..1b2e14c2e55 100644 --- a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/implementation/QueryClientImpl.java +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/implementation/QueryClientImpl.java @@ -63,6 +63,20 @@ public ConstantsImpl getConstants() { return this.constants; } + /** + * The SpecialCharsImpl object to access its operations. + */ + private final SpecialCharsImpl specialChars; + + /** + * Gets the SpecialCharsImpl object to access its operations. + * + * @return the SpecialCharsImpl object. + */ + public SpecialCharsImpl getSpecialChars() { + return this.specialChars; + } + /** * Initializes an instance of QueryClient client. * @@ -75,5 +89,6 @@ public QueryClientImpl(HttpPipeline httpPipeline, Instrumentation instrumentatio this.instrumentation = instrumentation; this.endpoint = endpoint; this.constants = new ConstantsImpl(this); + this.specialChars = new SpecialCharsImpl(this); } } diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/implementation/SpecialCharsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/implementation/SpecialCharsImpl.java new file mode 100644 index 00000000000..59303f3f77c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/implementation/SpecialCharsImpl.java @@ -0,0 +1,92 @@ +package parameters.query.implementation; + +import io.clientcore.core.annotations.ReturnType; +import io.clientcore.core.annotations.ServiceInterface; +import io.clientcore.core.annotations.ServiceMethod; +import io.clientcore.core.http.annotations.HostParam; +import io.clientcore.core.http.annotations.HttpRequestInformation; +import io.clientcore.core.http.annotations.QueryParam; +import io.clientcore.core.http.annotations.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.HttpResponseException; +import io.clientcore.core.http.models.RequestContext; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.instrumentation.Instrumentation; +import java.lang.reflect.InvocationTargetException; + +/** + * An instance of this class provides access to all the operations defined in SpecialChars. + */ +public final class SpecialCharsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SpecialCharsService service; + + /** + * The service client containing this operation class. + */ + private final QueryClientImpl client; + + /** + * The instance of instrumentation to report telemetry. + */ + private final Instrumentation instrumentation; + + /** + * Initializes an instance of SpecialCharsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SpecialCharsImpl(QueryClientImpl client) { + this.service = SpecialCharsService.getNewInstance(client.getHttpPipeline()); + this.client = client; + this.instrumentation = client.getInstrumentation(); + } + + /** + * The interface defining all the services for QueryClientSpecialChars to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "QueryClientSpecialChars", host = "{endpoint}") + public interface SpecialCharsService { + static SpecialCharsService getNewInstance(HttpPipeline pipeline) { + try { + Class clazz = Class.forName("parameters.query.implementation.SpecialCharsServiceImpl"); + return (SpecialCharsService) clazz.getMethod("getNewInstance", HttpPipeline.class) + .invoke(null, pipeline); + } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException + | InvocationTargetException e) { + throw new RuntimeException(e); + } + + } + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/parameters/query/special-char/dollarSign", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response dollarSign(@HostParam("endpoint") String endpoint, @QueryParam("$filter") String filter, + RequestContext requestContext); + } + + /** + * The dollarSign operation. + * + * @param filter The filter parameter. + * @param requestContext The context to configure the HTTP request before HTTP client sends it. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response dollarSignWithResponse(String filter, RequestContext requestContext) { + return this.instrumentation.instrumentWithResponse("Parameters.Query.SpecialChar.dollarSign", requestContext, + updatedContext -> { + return service.dollarSign(this.client.getEndpoint(), filter, updatedContext); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/Fish.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/Fish.java new file mode 100644 index 00000000000..e6bef5368d1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/Fish.java @@ -0,0 +1,102 @@ +package type.model.inheritance.singlediscriminator; + +import io.clientcore.core.annotations.Metadata; +import io.clientcore.core.annotations.MetadataProperties; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * A discriminated model with no defined subtypes. The discriminator is declared but no models extend it. + */ +@Metadata(properties = { MetadataProperties.IMMUTABLE }) +public final class Fish implements JsonSerializable { + /* + * The kind property. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + private String kind = "Fish"; + + /* + * The size property. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + private final int size; + + /** + * Creates an instance of Fish class. + * + * @param size the size value to set. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + public Fish(int size) { + this.size = size; + } + + /** + * Get the kind property: The kind property. + * + * @return the kind value. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + public String getKind() { + return this.kind; + } + + /** + * Get the size property: The size property. + * + * @return the size value. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + public int getSize() { + return this.size; + } + + /** + * {@inheritDoc} + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("size", this.size); + jsonWriter.writeStringField("kind", this.kind); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Fish from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Fish if the JsonReader was pointing to an instance of it, or null if it was pointing to + * JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the Fish. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + public static Fish fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int size = 0; + String kind = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("size".equals(fieldName)) { + size = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = reader.getString(); + } else { + reader.skipChildren(); + } + } + Fish deserializedFish = new Fish(size); + deserializedFish.kind = kind; + + return deserializedFish; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java index 1d11f3a38ab..7ac8ce82995 100644 --- a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java @@ -247,4 +247,66 @@ public Response getLegacyModelWithResponse(RequestContext requestConte public Dinosaur getLegacyModel() { return getLegacyModelWithResponse(RequestContext.none()).getValue(); } + + /** + * The getNoSubtypesModel operation. + * + * @param requestContext The context to configure the HTTP request before HTTP client sends it. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a discriminated model with no defined subtypes along with {@link Response}. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNoSubtypesModelWithResponse(RequestContext requestContext) { + return this.instrumentation.instrumentWithResponse( + "Type.Model.Inheritance.SingleDiscriminator.getNoSubtypesModel", requestContext, + updatedContext -> this.serviceClient.getNoSubtypesModelWithResponse(updatedContext)); + } + + /** + * The getNoSubtypesModel operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a discriminated model with no defined subtypes. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @ServiceMethod(returns = ReturnType.SINGLE) + public Fish getNoSubtypesModel() { + return getNoSubtypesModelWithResponse(RequestContext.none()).getValue(); + } + + /** + * The putNoSubtypesModel operation. + * + * @param input The input parameter. + * @param requestContext The context to configure the HTTP request before HTTP client sends it. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putNoSubtypesModelWithResponse(Fish input, RequestContext requestContext) { + return this.instrumentation.instrumentWithResponse( + "Type.Model.Inheritance.SingleDiscriminator.putNoSubtypesModel", requestContext, + updatedContext -> this.serviceClient.putNoSubtypesModelWithResponse(input, updatedContext)); + } + + /** + * The putNoSubtypesModel operation. + * + * @param input The input parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @ServiceMethod(returns = ReturnType.SINGLE) + public void putNoSubtypesModel(Fish input) { + putNoSubtypesModelWithResponse(input, RequestContext.none()); + } } diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java index 96a1bcb7d1e..e83deee5158 100644 --- a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java @@ -17,6 +17,7 @@ import java.lang.reflect.InvocationTargetException; import type.model.inheritance.singlediscriminator.Bird; import type.model.inheritance.singlediscriminator.Dinosaur; +import type.model.inheritance.singlediscriminator.Fish; /** * Initializes a new instance of the SingleDiscriminatorClient type. @@ -158,6 +159,23 @@ Response getWrongDiscriminator(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionDetail Response getLegacyModel(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestContext requestContext); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/model/inheritance/single-discriminator/no-subtypes/model", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getNoSubtypesModel(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestContext requestContext); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/model/inheritance/single-discriminator/no-subtypes/model", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putNoSubtypesModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") Fish input, + RequestContext requestContext); } /** @@ -291,4 +309,41 @@ public Response getLegacyModelWithResponse(RequestContext requestConte return service.getLegacyModel(this.getEndpoint(), accept, updatedContext); }); } + + /** + * The getNoSubtypesModel operation. + * + * @param requestContext The context to configure the HTTP request before HTTP client sends it. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a discriminated model with no defined subtypes along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNoSubtypesModelWithResponse(RequestContext requestContext) { + return this.instrumentation.instrumentWithResponse( + "Type.Model.Inheritance.SingleDiscriminator.getNoSubtypesModel", requestContext, updatedContext -> { + final String accept = "application/json"; + return service.getNoSubtypesModel(this.getEndpoint(), accept, updatedContext); + }); + } + + /** + * The putNoSubtypesModel operation. + * + * @param input The input parameter. + * @param requestContext The context to configure the HTTP request before HTTP client sends it. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putNoSubtypesModelWithResponse(Fish input, RequestContext requestContext) { + return this.instrumentation.instrumentWithResponse( + "Type.Model.Inheritance.SingleDiscriminator.putNoSubtypesModel", requestContext, updatedContext -> { + final String contentType = "application/json"; + return service.putNoSubtypesModel(this.getEndpoint(), contentType, input, updatedContext); + }); + } } diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-bodyroot_metadata.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-bodyroot_metadata.json new file mode 100644 index 00000000000..d69c725b70b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-bodyroot_metadata.json @@ -0,0 +1 @@ +{"flavor":"generic","apiVersions":{},"crossLanguagePackageId":"Parameters.BodyRoot","crossLanguageVersion":"1b93bc1e60f7","crossLanguageDefinitions":{"parameters.bodyroot.BodyRootClient":"Parameters.BodyRoot","parameters.bodyroot.BodyRootClientBuilder":"Parameters.BodyRoot","parameters.bodyroot.BodyRootModel":"Parameters.BodyRoot.BodyRootModel"},"generatedFiles":["src/main/java/module-info.java","src/main/java/parameters/bodyroot/BodyRootClient.java","src/main/java/parameters/bodyroot/BodyRootClientBuilder.java","src/main/java/parameters/bodyroot/BodyRootModel.java","src/main/java/parameters/bodyroot/implementation/BodyRootClientImpl.java","src/main/java/parameters/bodyroot/implementation/package-info.java","src/main/java/parameters/bodyroot/package-info.java"]} \ No newline at end of file diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-query_metadata.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-query_metadata.json index 0eece0cddea..d491ee294d3 100644 --- a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-query_metadata.json +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-query_metadata.json @@ -1 +1 @@ -{"flavor":"generic","apiVersions":{},"crossLanguagePackageId":"Parameters.Query","crossLanguageVersion":"e2bfb58d3cc1","crossLanguageDefinitions":{"parameters.query.QueryClient":"Parameters.Query.Constant","parameters.query.QueryClientBuilder":"Parameters.Query"},"generatedFiles":["src/main/java/module-info.java","src/main/java/parameters/query/QueryClient.java","src/main/java/parameters/query/QueryClientBuilder.java","src/main/java/parameters/query/implementation/ConstantsImpl.java","src/main/java/parameters/query/implementation/QueryClientImpl.java","src/main/java/parameters/query/implementation/package-info.java","src/main/java/parameters/query/package-info.java"]} \ No newline at end of file +{"flavor":"generic","apiVersions":{},"crossLanguagePackageId":"Parameters.Query","crossLanguageVersion":"d221aa20c419","crossLanguageDefinitions":{"parameters.query.ConstantClient":"Parameters.Query.Constant","parameters.query.QueryClientBuilder":"Parameters.Query","parameters.query.SpecialCharClient":"Parameters.Query.SpecialChar"},"generatedFiles":["src/main/java/module-info.java","src/main/java/parameters/query/ConstantClient.java","src/main/java/parameters/query/QueryClientBuilder.java","src/main/java/parameters/query/SpecialCharClient.java","src/main/java/parameters/query/implementation/ConstantsImpl.java","src/main/java/parameters/query/implementation/QueryClientImpl.java","src/main/java/parameters/query/implementation/SpecialCharsImpl.java","src/main/java/parameters/query/implementation/package-info.java","src/main/java/parameters/query/package-info.java"]} \ No newline at end of file diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-inheritance-singlediscriminator_metadata.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-inheritance-singlediscriminator_metadata.json index 2bbf23e7b20..9857c4dc04c 100644 --- a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-inheritance-singlediscriminator_metadata.json +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-inheritance-singlediscriminator_metadata.json @@ -1 +1 @@ -{"flavor":"generic","apiVersions":{},"crossLanguagePackageId":"Type.Model.Inheritance.SingleDiscriminator","crossLanguageVersion":"301c4a3b5af0","crossLanguageDefinitions":{"type.model.inheritance.singlediscriminator.Bird":"Type.Model.Inheritance.SingleDiscriminator.Bird","type.model.inheritance.singlediscriminator.Dinosaur":"Type.Model.Inheritance.SingleDiscriminator.Dinosaur","type.model.inheritance.singlediscriminator.Eagle":"Type.Model.Inheritance.SingleDiscriminator.Eagle","type.model.inheritance.singlediscriminator.Goose":"Type.Model.Inheritance.SingleDiscriminator.Goose","type.model.inheritance.singlediscriminator.SeaGull":"Type.Model.Inheritance.SingleDiscriminator.SeaGull","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient":"Type.Model.Inheritance.SingleDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorClientBuilder":"Type.Model.Inheritance.SingleDiscriminator","type.model.inheritance.singlediscriminator.Sparrow":"Type.Model.Inheritance.SingleDiscriminator.Sparrow","type.model.inheritance.singlediscriminator.TRex":"Type.Model.Inheritance.SingleDiscriminator.TRex"},"generatedFiles":["src/main/java/module-info.java","src/main/java/type/model/inheritance/singlediscriminator/Bird.java","src/main/java/type/model/inheritance/singlediscriminator/Dinosaur.java","src/main/java/type/model/inheritance/singlediscriminator/Eagle.java","src/main/java/type/model/inheritance/singlediscriminator/Goose.java","src/main/java/type/model/inheritance/singlediscriminator/SeaGull.java","src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java","src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClientBuilder.java","src/main/java/type/model/inheritance/singlediscriminator/Sparrow.java","src/main/java/type/model/inheritance/singlediscriminator/TRex.java","src/main/java/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java","src/main/java/type/model/inheritance/singlediscriminator/implementation/package-info.java","src/main/java/type/model/inheritance/singlediscriminator/package-info.java"]} \ No newline at end of file +{"flavor":"generic","apiVersions":{},"crossLanguagePackageId":"Type.Model.Inheritance.SingleDiscriminator","crossLanguageVersion":"d008d2bf96fe","crossLanguageDefinitions":{"type.model.inheritance.singlediscriminator.Bird":"Type.Model.Inheritance.SingleDiscriminator.Bird","type.model.inheritance.singlediscriminator.Dinosaur":"Type.Model.Inheritance.SingleDiscriminator.Dinosaur","type.model.inheritance.singlediscriminator.Eagle":"Type.Model.Inheritance.SingleDiscriminator.Eagle","type.model.inheritance.singlediscriminator.Fish":"Type.Model.Inheritance.SingleDiscriminator.Fish","type.model.inheritance.singlediscriminator.Goose":"Type.Model.Inheritance.SingleDiscriminator.Goose","type.model.inheritance.singlediscriminator.SeaGull":"Type.Model.Inheritance.SingleDiscriminator.SeaGull","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient":"Type.Model.Inheritance.SingleDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorClientBuilder":"Type.Model.Inheritance.SingleDiscriminator","type.model.inheritance.singlediscriminator.Sparrow":"Type.Model.Inheritance.SingleDiscriminator.Sparrow","type.model.inheritance.singlediscriminator.TRex":"Type.Model.Inheritance.SingleDiscriminator.TRex"},"generatedFiles":["src/main/java/module-info.java","src/main/java/type/model/inheritance/singlediscriminator/Bird.java","src/main/java/type/model/inheritance/singlediscriminator/Dinosaur.java","src/main/java/type/model/inheritance/singlediscriminator/Eagle.java","src/main/java/type/model/inheritance/singlediscriminator/Fish.java","src/main/java/type/model/inheritance/singlediscriminator/Goose.java","src/main/java/type/model/inheritance/singlediscriminator/SeaGull.java","src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java","src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClientBuilder.java","src/main/java/type/model/inheritance/singlediscriminator/Sparrow.java","src/main/java/type/model/inheritance/singlediscriminator/TRex.java","src/main/java/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java","src/main/java/type/model/inheritance/singlediscriminator/implementation/package-info.java","src/main/java/type/model/inheritance/singlediscriminator/package-info.java"]} \ No newline at end of file diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/bodyroot/BodyRootTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/bodyroot/BodyRootTests.java new file mode 100644 index 00000000000..75cdcb9d9e8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/bodyroot/BodyRootTests.java @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package parameters.bodyroot; + +import org.junit.jupiter.api.Test; + +public class BodyRootTests { + + private final BodyRootClient client = new BodyRootClientBuilder().buildClient(); + + @Test + public void testNested() { + client.nested(new BodyRootModel().setCategory("widget").setLinkType("hard").setWasSuccessful(true)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/query/QueryTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/query/QueryTests.java index fbed3285da3..8f512938876 100644 --- a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/query/QueryTests.java +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/query/QueryTests.java @@ -3,14 +3,22 @@ package parameters.query; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; public class QueryTests { - private final QueryClient client = new QueryClientBuilder().buildQueryClient(); + private final ConstantClient constantClient = new QueryClientBuilder().buildConstantClient(); + private final SpecialCharClient specialCharClient = new QueryClientBuilder().buildSpecialCharClient(); @Test public void testConstant() { - client.post(); + constantClient.post(); + } + + @Test + @Disabled("Blocked until @typespec/http-specs publishes the dollar-sign route fix") + public void testDollarSign() { + specialCharClient.dollarSign("status eq 'active'"); } } diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/inheritance/SingleDiscriminatorTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/inheritance/SingleDiscriminatorTest.java index 43453f622ab..65ad3d70d0f 100644 --- a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/inheritance/SingleDiscriminatorTest.java +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/inheritance/SingleDiscriminatorTest.java @@ -7,6 +7,7 @@ import org.junit.jupiter.api.Test; import type.model.inheritance.singlediscriminator.Bird; import type.model.inheritance.singlediscriminator.Eagle; +import type.model.inheritance.singlediscriminator.Fish; import type.model.inheritance.singlediscriminator.Goose; import type.model.inheritance.singlediscriminator.SeaGull; import type.model.inheritance.singlediscriminator.SingleDiscriminatorClient; @@ -36,4 +37,13 @@ public void testSingleDiscriminator() { Assertions.assertEquals(Sparrow.class, recursiveModel.getHate().get("key3").getClass()); client.putRecursiveModel(recursiveModel); } + + @Test + public void testNoSubtypesModel() { + Fish fish = client.getNoSubtypesModel(); + Assertions.assertNotNull(fish); + Assertions.assertEquals(10, fish.getSize()); + + client.putNoSubtypesModel(fish); + } } diff --git a/packages/http-client-java/generator/http-client-generator-test/package.json b/packages/http-client-java/generator/http-client-generator-test/package.json index 8549c21e66b..f92c6c8848c 100644 --- a/packages/http-client-java/generator/http-client-generator-test/package.json +++ b/packages/http-client-java/generator/http-client-generator-test/package.json @@ -14,25 +14,25 @@ "dependencies": { "@typespec/spector": "0.1.0-alpha.25", "@typespec/spec-api": "0.1.0-alpha.14", - "@typespec/http-specs": "0.1.0-alpha.37", - "@azure-tools/azure-http-specs": "0.1.0-alpha.41", - "@typespec/http-client-java": "file:../../typespec-http-client-java-0.8.1.tgz", + "@typespec/http-specs": "0.1.0-alpha.38", + "@azure-tools/azure-http-specs": "0.1.0-alpha.42", + "@typespec/http-client-java": "file:../../typespec-http-client-java-0.9.0.tgz", "@typespec/http-client-java-tests": "file:" }, "overrides": { - "@typespec/compiler": "1.12.0", - "@typespec/http": "1.12.0", - "@typespec/rest": "0.82.0", - "@typespec/versioning": "0.82.0", - "@typespec/openapi": "1.12.0", - "@typespec/xml": "0.82.0", - "@typespec/events": "0.82.0", - "@typespec/sse": "0.82.0", - "@typespec/streams": "0.82.0", - "@azure-tools/typespec-azure-core": "0.68.0", - "@azure-tools/typespec-client-generator-core": "0.68.4", - "@azure-tools/typespec-azure-resource-manager": "0.68.0", - "@azure-tools/typespec-autorest": "0.68.0" + "@typespec/compiler": "1.13.0", + "@typespec/http": "1.13.0", + "@typespec/rest": "0.83.0", + "@typespec/versioning": "0.83.0", + "@typespec/openapi": "1.13.0", + "@typespec/xml": "0.83.0", + "@typespec/events": "0.83.0", + "@typespec/sse": "0.83.0", + "@typespec/streams": "0.83.0", + "@azure-tools/typespec-azure-core": "0.69.0", + "@azure-tools/typespec-client-generator-core": "0.69.0", + "@azure-tools/typespec-azure-resource-manager": "0.69.0", + "@azure-tools/typespec-autorest": "0.69.0" }, "private": true } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/CommonPropertiesManager.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/CommonPropertiesManager.java index cc0e7a13895..18659a6b52b 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/CommonPropertiesManager.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/CommonPropertiesManager.java @@ -5,9 +5,11 @@ package azure.resourcemanager.commonproperties; import azure.resourcemanager.commonproperties.fluent.CommonPropertiesClient; +import azure.resourcemanager.commonproperties.implementation.ArmResourceIdentifiersImpl; import azure.resourcemanager.commonproperties.implementation.CommonPropertiesClientBuilder; import azure.resourcemanager.commonproperties.implementation.ErrorsImpl; import azure.resourcemanager.commonproperties.implementation.ManagedIdentitiesImpl; +import azure.resourcemanager.commonproperties.models.ArmResourceIdentifiers; import azure.resourcemanager.commonproperties.models.Errors; import azure.resourcemanager.commonproperties.models.ManagedIdentities; import com.azure.core.credential.TokenCredential; @@ -47,6 +49,8 @@ public final class CommonPropertiesManager { private Errors errors; + private ArmResourceIdentifiers armResourceIdentifiers; + private final CommonPropertiesClient clientObject; private CommonPropertiesManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { @@ -286,6 +290,19 @@ public Errors errors() { return errors; } + /** + * Gets the resource collection API of ArmResourceIdentifiers. It manages ArmResourceIdentifierResource. + * + * @return Resource collection API of ArmResourceIdentifiers. + */ + public ArmResourceIdentifiers armResourceIdentifiers() { + if (this.armResourceIdentifiers == null) { + this.armResourceIdentifiers + = new ArmResourceIdentifiersImpl(clientObject.getArmResourceIdentifiers(), this); + } + return armResourceIdentifiers; + } + /** * Gets wrapped service client CommonPropertiesClient providing direct access to the underlying auto-generated API * implementation, based on Azure REST API. diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/fluent/ArmResourceIdentifiersClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/fluent/ArmResourceIdentifiersClient.java new file mode 100644 index 00000000000..47072b69f83 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/fluent/ArmResourceIdentifiersClient.java @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.commonproperties.fluent; + +import azure.resourcemanager.commonproperties.fluent.models.ArmResourceIdentifierResourceInner; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** + * An instance of this class provides access to all the operations defined in ArmResourceIdentifiersClient. + */ +public interface ArmResourceIdentifiersClient { + /** + * Get a ArmResourceIdentifierResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param armResourceIdentifierResourceName arm resource name for path. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ArmResourceIdentifierResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getByResourceGroupWithResponse(String resourceGroupName, + String armResourceIdentifierResourceName, Context context); + + /** + * Get a ArmResourceIdentifierResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param armResourceIdentifierResourceName arm resource name for path. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ArmResourceIdentifierResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ArmResourceIdentifierResourceInner getByResourceGroup(String resourceGroupName, + String armResourceIdentifierResourceName); + + /** + * Create a ArmResourceIdentifierResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param armResourceIdentifierResourceName arm resource name for path. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete tracked resource types can be created by aliasing this type using a specific property type along + * with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response createOrReplaceWithResponse(String resourceGroupName, + String armResourceIdentifierResourceName, ArmResourceIdentifierResourceInner resource, Context context); + + /** + * Create a ArmResourceIdentifierResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param armResourceIdentifierResourceName arm resource name for path. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete tracked resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ArmResourceIdentifierResourceInner createOrReplace(String resourceGroupName, + String armResourceIdentifierResourceName, ArmResourceIdentifierResourceInner resource); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/fluent/CommonPropertiesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/fluent/CommonPropertiesClient.java index 89b218eb72d..0209b4d61af 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/fluent/CommonPropertiesClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/fluent/CommonPropertiesClient.java @@ -59,4 +59,11 @@ public interface CommonPropertiesClient { * @return the ErrorsClient object. */ ErrorsClient getErrors(); + + /** + * Gets the ArmResourceIdentifiersClient object to access its operations. + * + * @return the ArmResourceIdentifiersClient object. + */ + ArmResourceIdentifiersClient getArmResourceIdentifiers(); } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/fluent/models/ArmResourceIdentifierResourceInner.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/fluent/models/ArmResourceIdentifierResourceInner.java new file mode 100644 index 00000000000..438da6b1ec3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/fluent/models/ArmResourceIdentifierResourceInner.java @@ -0,0 +1,183 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.commonproperties.fluent.models; + +import azure.resourcemanager.commonproperties.models.ArmResourceIdentifierResourceProperties; +import com.azure.core.annotation.Fluent; +import com.azure.core.management.Resource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * Concrete tracked resource types can be created by aliasing this type using a specific property type. + */ +@Fluent +public final class ArmResourceIdentifierResourceInner extends Resource { + /* + * The resource-specific properties for this resource. + */ + private ArmResourceIdentifierResourceProperties properties; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * The type of the resource. + */ + private String type; + + /* + * The name of the resource. + */ + private String name; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /** + * Creates an instance of ArmResourceIdentifierResourceInner class. + */ + public ArmResourceIdentifierResourceInner() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public ArmResourceIdentifierResourceProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the ArmResourceIdentifierResourceInner object itself. + */ + public ArmResourceIdentifierResourceInner withProperties(ArmResourceIdentifierResourceProperties properties) { + this.properties = properties; + return this; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * {@inheritDoc} + */ + @Override + public ArmResourceIdentifierResourceInner withLocation(String location) { + super.withLocation(location); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ArmResourceIdentifierResourceInner withTags(Map tags) { + super.withTags(tags); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("location", location()); + jsonWriter.writeMapField("tags", tags(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeJsonField("properties", this.properties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ArmResourceIdentifierResourceInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ArmResourceIdentifierResourceInner if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ArmResourceIdentifierResourceInner. + */ + public static ArmResourceIdentifierResourceInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ArmResourceIdentifierResourceInner deserializedArmResourceIdentifierResourceInner + = new ArmResourceIdentifierResourceInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedArmResourceIdentifierResourceInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedArmResourceIdentifierResourceInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedArmResourceIdentifierResourceInner.type = reader.getString(); + } else if ("location".equals(fieldName)) { + deserializedArmResourceIdentifierResourceInner.withLocation(reader.getString()); + } else if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + deserializedArmResourceIdentifierResourceInner.withTags(tags); + } else if ("properties".equals(fieldName)) { + deserializedArmResourceIdentifierResourceInner.properties + = ArmResourceIdentifierResourceProperties.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedArmResourceIdentifierResourceInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedArmResourceIdentifierResourceInner; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/implementation/ArmResourceIdentifierResourceImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/implementation/ArmResourceIdentifierResourceImpl.java new file mode 100644 index 00000000000..5d51e499999 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/implementation/ArmResourceIdentifierResourceImpl.java @@ -0,0 +1,146 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.commonproperties.implementation; + +import azure.resourcemanager.commonproperties.fluent.models.ArmResourceIdentifierResourceInner; +import azure.resourcemanager.commonproperties.models.ArmResourceIdentifierResource; +import azure.resourcemanager.commonproperties.models.ArmResourceIdentifierResourceProperties; +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import java.util.Collections; +import java.util.Map; + +public final class ArmResourceIdentifierResourceImpl + implements ArmResourceIdentifierResource, ArmResourceIdentifierResource.Definition { + private ArmResourceIdentifierResourceInner innerObject; + + private final azure.resourcemanager.commonproperties.CommonPropertiesManager serviceManager; + + ArmResourceIdentifierResourceImpl(ArmResourceIdentifierResourceInner innerObject, + azure.resourcemanager.commonproperties.CommonPropertiesManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public String location() { + return this.innerModel().location(); + } + + public Map tags() { + Map inner = this.innerModel().tags(); + if (inner != null) { + return Collections.unmodifiableMap(inner); + } else { + return Collections.emptyMap(); + } + } + + public ArmResourceIdentifierResourceProperties properties() { + return this.innerModel().properties(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public Region region() { + return Region.fromName(this.regionName()); + } + + public String regionName() { + return this.location(); + } + + public ArmResourceIdentifierResourceInner innerModel() { + return this.innerObject; + } + + private azure.resourcemanager.commonproperties.CommonPropertiesManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String armResourceIdentifierResourceName; + + public ArmResourceIdentifierResourceImpl withExistingResourceGroup(String resourceGroupName) { + this.resourceGroupName = resourceGroupName; + return this; + } + + public ArmResourceIdentifierResource create() { + this.innerObject = serviceManager.serviceClient() + .getArmResourceIdentifiers() + .createOrReplaceWithResponse(resourceGroupName, armResourceIdentifierResourceName, this.innerModel(), + Context.NONE) + .getValue(); + return this; + } + + public ArmResourceIdentifierResource create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getArmResourceIdentifiers() + .createOrReplaceWithResponse(resourceGroupName, armResourceIdentifierResourceName, this.innerModel(), + context) + .getValue(); + return this; + } + + ArmResourceIdentifierResourceImpl(String name, + azure.resourcemanager.commonproperties.CommonPropertiesManager serviceManager) { + this.innerObject = new ArmResourceIdentifierResourceInner(); + this.serviceManager = serviceManager; + this.armResourceIdentifierResourceName = name; + } + + public ArmResourceIdentifierResource refresh() { + this.innerObject = serviceManager.serviceClient() + .getArmResourceIdentifiers() + .getByResourceGroupWithResponse(resourceGroupName, armResourceIdentifierResourceName, Context.NONE) + .getValue(); + return this; + } + + public ArmResourceIdentifierResource refresh(Context context) { + this.innerObject = serviceManager.serviceClient() + .getArmResourceIdentifiers() + .getByResourceGroupWithResponse(resourceGroupName, armResourceIdentifierResourceName, context) + .getValue(); + return this; + } + + public ArmResourceIdentifierResourceImpl withRegion(Region location) { + this.innerModel().withLocation(location.toString()); + return this; + } + + public ArmResourceIdentifierResourceImpl withRegion(String location) { + this.innerModel().withLocation(location); + return this; + } + + public ArmResourceIdentifierResourceImpl withTags(Map tags) { + this.innerModel().withTags(tags); + return this; + } + + public ArmResourceIdentifierResourceImpl withProperties(ArmResourceIdentifierResourceProperties properties) { + this.innerModel().withProperties(properties); + return this; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/implementation/ArmResourceIdentifiersClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/implementation/ArmResourceIdentifiersClientImpl.java new file mode 100644 index 00000000000..0ff805481b9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/implementation/ArmResourceIdentifiersClientImpl.java @@ -0,0 +1,260 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.commonproperties.implementation; + +import azure.resourcemanager.commonproperties.fluent.ArmResourceIdentifiersClient; +import azure.resourcemanager.commonproperties.fluent.models.ArmResourceIdentifierResourceInner; +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in ArmResourceIdentifiersClient. + */ +public final class ArmResourceIdentifiersClientImpl implements ArmResourceIdentifiersClient { + /** + * The proxy service used to perform REST calls. + */ + private final ArmResourceIdentifiersService service; + + /** + * The service client containing this operation class. + */ + private final CommonPropertiesClientImpl client; + + /** + * Initializes an instance of ArmResourceIdentifiersClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ArmResourceIdentifiersClientImpl(CommonPropertiesClientImpl client) { + this.service = RestProxy.create(ArmResourceIdentifiersService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for CommonPropertiesClientArmResourceIdentifiers to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "CommonPropertiesClientArmResourceIdentifiers") + public interface ArmResourceIdentifiersService { + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/armResourceIdentifierResources/{armResourceIdentifierResourceName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> getByResourceGroup(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("armResourceIdentifierResourceName") String armResourceIdentifierResourceName, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/armResourceIdentifierResources/{armResourceIdentifierResourceName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response getByResourceGroupSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("armResourceIdentifierResourceName") String armResourceIdentifierResourceName, + @HeaderParam("Accept") String accept, Context context); + + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/armResourceIdentifierResources/{armResourceIdentifierResourceName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> createOrReplace(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("armResourceIdentifierResourceName") String armResourceIdentifierResourceName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") ArmResourceIdentifierResourceInner resource, Context context); + + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/armResourceIdentifierResources/{armResourceIdentifierResourceName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response createOrReplaceSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("armResourceIdentifierResourceName") String armResourceIdentifierResourceName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") ArmResourceIdentifierResourceInner resource, Context context); + } + + /** + * Get a ArmResourceIdentifierResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param armResourceIdentifierResourceName arm resource name for path. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ArmResourceIdentifierResource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + getByResourceGroupWithResponseAsync(String resourceGroupName, String armResourceIdentifierResourceName) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, armResourceIdentifierResourceName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a ArmResourceIdentifierResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param armResourceIdentifierResourceName arm resource name for path. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ArmResourceIdentifierResource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getByResourceGroupAsync(String resourceGroupName, + String armResourceIdentifierResourceName) { + return getByResourceGroupWithResponseAsync(resourceGroupName, armResourceIdentifierResourceName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get a ArmResourceIdentifierResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param armResourceIdentifierResourceName arm resource name for path. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ArmResourceIdentifierResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getByResourceGroupWithResponse(String resourceGroupName, + String armResourceIdentifierResourceName, Context context) { + final String accept = "application/json"; + return service.getByResourceGroupSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, armResourceIdentifierResourceName, accept, context); + } + + /** + * Get a ArmResourceIdentifierResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param armResourceIdentifierResourceName arm resource name for path. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ArmResourceIdentifierResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ArmResourceIdentifierResourceInner getByResourceGroup(String resourceGroupName, + String armResourceIdentifierResourceName) { + return getByResourceGroupWithResponse(resourceGroupName, armResourceIdentifierResourceName, Context.NONE) + .getValue(); + } + + /** + * Create a ArmResourceIdentifierResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param armResourceIdentifierResourceName arm resource name for path. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete tracked resource types can be created by aliasing this type using a specific property type along + * with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrReplaceWithResponseAsync( + String resourceGroupName, String armResourceIdentifierResourceName, + ArmResourceIdentifierResourceInner resource) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createOrReplace(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, armResourceIdentifierResourceName, contentType, + accept, resource, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a ArmResourceIdentifierResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param armResourceIdentifierResourceName arm resource name for path. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete tracked resource types can be created by aliasing this type using a specific property type on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrReplaceAsync(String resourceGroupName, + String armResourceIdentifierResourceName, ArmResourceIdentifierResourceInner resource) { + return createOrReplaceWithResponseAsync(resourceGroupName, armResourceIdentifierResourceName, resource) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Create a ArmResourceIdentifierResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param armResourceIdentifierResourceName arm resource name for path. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete tracked resource types can be created by aliasing this type using a specific property type along + * with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrReplaceWithResponse(String resourceGroupName, + String armResourceIdentifierResourceName, ArmResourceIdentifierResourceInner resource, Context context) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createOrReplaceSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, armResourceIdentifierResourceName, contentType, accept, + resource, context); + } + + /** + * Create a ArmResourceIdentifierResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param armResourceIdentifierResourceName arm resource name for path. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete tracked resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ArmResourceIdentifierResourceInner createOrReplace(String resourceGroupName, + String armResourceIdentifierResourceName, ArmResourceIdentifierResourceInner resource) { + return createOrReplaceWithResponse(resourceGroupName, armResourceIdentifierResourceName, resource, Context.NONE) + .getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/implementation/ArmResourceIdentifiersImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/implementation/ArmResourceIdentifiersImpl.java new file mode 100644 index 00000000000..59779ecd66c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/implementation/ArmResourceIdentifiersImpl.java @@ -0,0 +1,90 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.commonproperties.implementation; + +import azure.resourcemanager.commonproperties.fluent.ArmResourceIdentifiersClient; +import azure.resourcemanager.commonproperties.fluent.models.ArmResourceIdentifierResourceInner; +import azure.resourcemanager.commonproperties.models.ArmResourceIdentifierResource; +import azure.resourcemanager.commonproperties.models.ArmResourceIdentifiers; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; + +public final class ArmResourceIdentifiersImpl implements ArmResourceIdentifiers { + private static final ClientLogger LOGGER = new ClientLogger(ArmResourceIdentifiersImpl.class); + + private final ArmResourceIdentifiersClient innerClient; + + private final azure.resourcemanager.commonproperties.CommonPropertiesManager serviceManager; + + public ArmResourceIdentifiersImpl(ArmResourceIdentifiersClient innerClient, + azure.resourcemanager.commonproperties.CommonPropertiesManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getByResourceGroupWithResponse(String resourceGroupName, + String armResourceIdentifierResourceName, Context context) { + Response inner = this.serviceClient() + .getByResourceGroupWithResponse(resourceGroupName, armResourceIdentifierResourceName, context); + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new ArmResourceIdentifierResourceImpl(inner.getValue(), this.manager())); + } + + public ArmResourceIdentifierResource getByResourceGroup(String resourceGroupName, + String armResourceIdentifierResourceName) { + ArmResourceIdentifierResourceInner inner + = this.serviceClient().getByResourceGroup(resourceGroupName, armResourceIdentifierResourceName); + if (inner != null) { + return new ArmResourceIdentifierResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public ArmResourceIdentifierResource getById(String id) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String armResourceIdentifierResourceName + = ResourceManagerUtils.getValueFromIdByName(id, "armResourceIdentifierResources"); + if (armResourceIdentifierResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String.format( + "The resource ID '%s' is not valid. Missing path segment 'armResourceIdentifierResources'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, armResourceIdentifierResourceName, Context.NONE) + .getValue(); + } + + public Response getByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String armResourceIdentifierResourceName + = ResourceManagerUtils.getValueFromIdByName(id, "armResourceIdentifierResources"); + if (armResourceIdentifierResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String.format( + "The resource ID '%s' is not valid. Missing path segment 'armResourceIdentifierResources'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, armResourceIdentifierResourceName, context); + } + + private ArmResourceIdentifiersClient serviceClient() { + return this.innerClient; + } + + private azure.resourcemanager.commonproperties.CommonPropertiesManager manager() { + return this.serviceManager; + } + + public ArmResourceIdentifierResourceImpl define(String name) { + return new ArmResourceIdentifierResourceImpl(name, this.manager()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/implementation/CommonPropertiesClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/implementation/CommonPropertiesClientImpl.java index 0c015e90c3f..bf67d5c1129 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/implementation/CommonPropertiesClientImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/implementation/CommonPropertiesClientImpl.java @@ -4,6 +4,7 @@ package azure.resourcemanager.commonproperties.implementation; +import azure.resourcemanager.commonproperties.fluent.ArmResourceIdentifiersClient; import azure.resourcemanager.commonproperties.fluent.CommonPropertiesClient; import azure.resourcemanager.commonproperties.fluent.ErrorsClient; import azure.resourcemanager.commonproperties.fluent.ManagedIdentitiesClient; @@ -155,6 +156,20 @@ public ErrorsClient getErrors() { return this.errors; } + /** + * The ArmResourceIdentifiersClient object to access its operations. + */ + private final ArmResourceIdentifiersClient armResourceIdentifiers; + + /** + * Gets the ArmResourceIdentifiersClient object to access its operations. + * + * @return the ArmResourceIdentifiersClient object. + */ + public ArmResourceIdentifiersClient getArmResourceIdentifiers() { + return this.armResourceIdentifiers; + } + /** * Initializes an instance of CommonPropertiesClient client. * @@ -175,6 +190,7 @@ public ErrorsClient getErrors() { this.apiVersion = "2023-12-01-preview"; this.managedIdentities = new ManagedIdentitiesClientImpl(this); this.errors = new ErrorsClientImpl(this); + this.armResourceIdentifiers = new ArmResourceIdentifiersClientImpl(this); } /** diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/models/ArmResourceIdentifierResource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/models/ArmResourceIdentifierResource.java new file mode 100644 index 00000000000..8fe53caee64 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/models/ArmResourceIdentifierResource.java @@ -0,0 +1,200 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.commonproperties.models; + +import azure.resourcemanager.commonproperties.fluent.models.ArmResourceIdentifierResourceInner; +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import java.util.Map; + +/** + * An immutable client-side representation of ArmResourceIdentifierResource. + */ +public interface ArmResourceIdentifierResource { + /** + * Gets the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: The name of the resource. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: The type of the resource. + * + * @return the type value. + */ + String type(); + + /** + * Gets the location property: The geo-location where the resource lives. + * + * @return the location value. + */ + String location(); + + /** + * Gets the tags property: Resource tags. + * + * @return the tags value. + */ + Map tags(); + + /** + * Gets the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + ArmResourceIdentifierResourceProperties properties(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the region of the resource. + * + * @return the region of the resource. + */ + Region region(); + + /** + * Gets the name of the resource region. + * + * @return the name of the resource region. + */ + String regionName(); + + /** + * Gets the inner azure.resourcemanager.commonproperties.fluent.models.ArmResourceIdentifierResourceInner object. + * + * @return the inner object. + */ + ArmResourceIdentifierResourceInner innerModel(); + + /** + * The entirety of the ArmResourceIdentifierResource definition. + */ + interface Definition extends DefinitionStages.Blank, DefinitionStages.WithLocation, + DefinitionStages.WithResourceGroup, DefinitionStages.WithCreate { + } + + /** + * The ArmResourceIdentifierResource definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the ArmResourceIdentifierResource definition. + */ + interface Blank extends WithLocation { + } + + /** + * The stage of the ArmResourceIdentifierResource definition allowing to specify location. + */ + interface WithLocation { + /** + * Specifies the region for the resource. + * + * @param location The geo-location where the resource lives. + * @return the next definition stage. + */ + WithResourceGroup withRegion(Region location); + + /** + * Specifies the region for the resource. + * + * @param location The geo-location where the resource lives. + * @return the next definition stage. + */ + WithResourceGroup withRegion(String location); + } + + /** + * The stage of the ArmResourceIdentifierResource definition allowing to specify parent resource. + */ + interface WithResourceGroup { + /** + * Specifies resourceGroupName. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @return the next definition stage. + */ + WithCreate withExistingResourceGroup(String resourceGroupName); + } + + /** + * The stage of the ArmResourceIdentifierResource definition which contains all the minimum required properties + * for the resource to be created, but also allows for any other optional properties to be specified. + */ + interface WithCreate extends DefinitionStages.WithTags, DefinitionStages.WithProperties { + /** + * Executes the create request. + * + * @return the created resource. + */ + ArmResourceIdentifierResource create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + ArmResourceIdentifierResource create(Context context); + } + + /** + * The stage of the ArmResourceIdentifierResource definition allowing to specify tags. + */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + WithCreate withTags(Map tags); + } + + /** + * The stage of the ArmResourceIdentifierResource definition allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + WithCreate withProperties(ArmResourceIdentifierResourceProperties properties); + } + } + + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + ArmResourceIdentifierResource refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + ArmResourceIdentifierResource refresh(Context context); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/models/ArmResourceIdentifierResourceProperties.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/models/ArmResourceIdentifierResourceProperties.java new file mode 100644 index 00000000000..85435639270 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/models/ArmResourceIdentifierResourceProperties.java @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.commonproperties.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * ArmResourceIdentifier Resource Properties. + */ +@Fluent +public final class ArmResourceIdentifierResourceProperties + implements JsonSerializable { + /* + * The status of the last operation. + */ + private ResourceProvisioningState provisioningState; + + /* + * A basic ARM resource identifier without type or scopes. + */ + private String simpleArmId; + + /* + * An ARM resource identifier with type only. + */ + private String armIdWithType; + + /* + * An ARM resource identifier with type and scopes. + */ + private String armIdWithTypeAndScope; + + /* + * An ARM resource identifier with all scopes. + */ + private String armIdWithAllScopes; + + /** + * Creates an instance of ArmResourceIdentifierResourceProperties class. + */ + public ArmResourceIdentifierResourceProperties() { + } + + /** + * Get the provisioningState property: The status of the last operation. + * + * @return the provisioningState value. + */ + public ResourceProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Get the simpleArmId property: A basic ARM resource identifier without type or scopes. + * + * @return the simpleArmId value. + */ + public String simpleArmId() { + return this.simpleArmId; + } + + /** + * Set the simpleArmId property: A basic ARM resource identifier without type or scopes. + * + * @param simpleArmId the simpleArmId value to set. + * @return the ArmResourceIdentifierResourceProperties object itself. + */ + public ArmResourceIdentifierResourceProperties withSimpleArmId(String simpleArmId) { + this.simpleArmId = simpleArmId; + return this; + } + + /** + * Get the armIdWithType property: An ARM resource identifier with type only. + * + * @return the armIdWithType value. + */ + public String armIdWithType() { + return this.armIdWithType; + } + + /** + * Set the armIdWithType property: An ARM resource identifier with type only. + * + * @param armIdWithType the armIdWithType value to set. + * @return the ArmResourceIdentifierResourceProperties object itself. + */ + public ArmResourceIdentifierResourceProperties withArmIdWithType(String armIdWithType) { + this.armIdWithType = armIdWithType; + return this; + } + + /** + * Get the armIdWithTypeAndScope property: An ARM resource identifier with type and scopes. + * + * @return the armIdWithTypeAndScope value. + */ + public String armIdWithTypeAndScope() { + return this.armIdWithTypeAndScope; + } + + /** + * Set the armIdWithTypeAndScope property: An ARM resource identifier with type and scopes. + * + * @param armIdWithTypeAndScope the armIdWithTypeAndScope value to set. + * @return the ArmResourceIdentifierResourceProperties object itself. + */ + public ArmResourceIdentifierResourceProperties withArmIdWithTypeAndScope(String armIdWithTypeAndScope) { + this.armIdWithTypeAndScope = armIdWithTypeAndScope; + return this; + } + + /** + * Get the armIdWithAllScopes property: An ARM resource identifier with all scopes. + * + * @return the armIdWithAllScopes value. + */ + public String armIdWithAllScopes() { + return this.armIdWithAllScopes; + } + + /** + * Set the armIdWithAllScopes property: An ARM resource identifier with all scopes. + * + * @param armIdWithAllScopes the armIdWithAllScopes value to set. + * @return the ArmResourceIdentifierResourceProperties object itself. + */ + public ArmResourceIdentifierResourceProperties withArmIdWithAllScopes(String armIdWithAllScopes) { + this.armIdWithAllScopes = armIdWithAllScopes; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("simpleArmId", this.simpleArmId); + jsonWriter.writeStringField("armIdWithType", this.armIdWithType); + jsonWriter.writeStringField("armIdWithTypeAndScope", this.armIdWithTypeAndScope); + jsonWriter.writeStringField("armIdWithAllScopes", this.armIdWithAllScopes); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ArmResourceIdentifierResourceProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ArmResourceIdentifierResourceProperties if the JsonReader was pointing to an instance of + * it, or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ArmResourceIdentifierResourceProperties. + */ + public static ArmResourceIdentifierResourceProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ArmResourceIdentifierResourceProperties deserializedArmResourceIdentifierResourceProperties + = new ArmResourceIdentifierResourceProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("provisioningState".equals(fieldName)) { + deserializedArmResourceIdentifierResourceProperties.provisioningState + = ResourceProvisioningState.fromString(reader.getString()); + } else if ("simpleArmId".equals(fieldName)) { + deserializedArmResourceIdentifierResourceProperties.simpleArmId = reader.getString(); + } else if ("armIdWithType".equals(fieldName)) { + deserializedArmResourceIdentifierResourceProperties.armIdWithType = reader.getString(); + } else if ("armIdWithTypeAndScope".equals(fieldName)) { + deserializedArmResourceIdentifierResourceProperties.armIdWithTypeAndScope = reader.getString(); + } else if ("armIdWithAllScopes".equals(fieldName)) { + deserializedArmResourceIdentifierResourceProperties.armIdWithAllScopes = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedArmResourceIdentifierResourceProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/models/ArmResourceIdentifiers.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/models/ArmResourceIdentifiers.java new file mode 100644 index 00000000000..cbf3f717717 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/models/ArmResourceIdentifiers.java @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.commonproperties.models; + +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** + * Resource collection API of ArmResourceIdentifiers. + */ +public interface ArmResourceIdentifiers { + /** + * Get a ArmResourceIdentifierResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param armResourceIdentifierResourceName arm resource name for path. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ArmResourceIdentifierResource along with {@link Response}. + */ + Response getByResourceGroupWithResponse(String resourceGroupName, + String armResourceIdentifierResourceName, Context context); + + /** + * Get a ArmResourceIdentifierResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param armResourceIdentifierResourceName arm resource name for path. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ArmResourceIdentifierResource. + */ + ArmResourceIdentifierResource getByResourceGroup(String resourceGroupName, + String armResourceIdentifierResourceName); + + /** + * Get a ArmResourceIdentifierResource. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ArmResourceIdentifierResource along with {@link Response}. + */ + ArmResourceIdentifierResource getById(String id); + + /** + * Get a ArmResourceIdentifierResource. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ArmResourceIdentifierResource along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new ArmResourceIdentifierResource resource. + * + * @param name resource name. + * @return the first stage of the new ArmResourceIdentifierResource definition. + */ + ArmResourceIdentifierResource.DefinitionStages.Blank define(String name); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/models/ResourceProvisioningState.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/models/ResourceProvisioningState.java new file mode 100644 index 00000000000..40f4a38dd60 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/models/ResourceProvisioningState.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.commonproperties.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The provisioning state of a resource type. + */ +public final class ResourceProvisioningState extends ExpandableStringEnum { + /** + * Resource has been created. + */ + public static final ResourceProvisioningState SUCCEEDED = fromString("Succeeded"); + + /** + * Resource creation failed. + */ + public static final ResourceProvisioningState FAILED = fromString("Failed"); + + /** + * Resource creation was canceled. + */ + public static final ResourceProvisioningState CANCELED = fromString("Canceled"); + + /** + * Creates a new instance of ResourceProvisioningState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ResourceProvisioningState() { + } + + /** + * Creates or finds a ResourceProvisioningState from its string representation. + * + * @param name a name to look for. + * @return the corresponding ResourceProvisioningState. + */ + public static ResourceProvisioningState fromString(String name) { + return fromString(name, ResourceProvisioningState.class); + } + + /** + * Gets known ResourceProvisioningState values. + * + * @return known ResourceProvisioningState values. + */ + public static Collection values() { + return values(ResourceProvisioningState.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/ManagementGroupManager.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/ManagementGroupManager.java new file mode 100644 index 00000000000..6c91d0e4eb2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/ManagementGroupManager.java @@ -0,0 +1,282 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.managementgroup; + +import azure.resourcemanager.managementgroup.fluent.ManagementGroupClient; +import azure.resourcemanager.managementgroup.implementation.ManagementGroupChildResourcesImpl; +import azure.resourcemanager.managementgroup.implementation.ManagementGroupClientBuilder; +import azure.resourcemanager.managementgroup.models.ManagementGroupChildResources; +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.HttpPipelinePosition; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.AddHeadersFromContextPolicy; +import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryOptions; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * Entry point to ManagementGroupManager. + * Arm Resource Provider management API. + */ +public final class ManagementGroupManager { + private ManagementGroupChildResources managementGroupChildResources; + + private final ManagementGroupClient clientObject; + + private ManagementGroupManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = new ManagementGroupClientBuilder().pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of ManagementGroup service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the ManagementGroup service API instance. + */ + public static ManagementGroupManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return configure().authenticate(credential, profile); + } + + /** + * Creates an instance of ManagementGroup service API entry point. + * + * @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential. + * @param profile the Azure profile for client. + * @return the ManagementGroup service API instance. + */ + public static ManagementGroupManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return new ManagementGroupManager(httpPipeline, profile, null); + } + + /** + * Gets a Configurable instance that can be used to create ManagementGroupManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new ManagementGroupManager.Configurable(); + } + + /** + * The Configurable allowing configurations to be set. + */ + public static final class Configurable { + private static final ClientLogger LOGGER = new ClientLogger(Configurable.class); + private static final String SDK_VERSION = "version"; + private static final Map PROPERTIES + = CoreUtils.getProperties("azure-resourcemanager-managementgroup-generated.properties"); + + private HttpClient httpClient; + private HttpLogOptions httpLogOptions; + private final List policies = new ArrayList<>(); + private final List scopes = new ArrayList<>(); + private RetryPolicy retryPolicy; + private RetryOptions retryOptions; + private Duration defaultPollInterval; + + private Configurable() { + } + + /** + * Sets the http client. + * + * @param httpClient the HTTP client. + * @return the configurable object itself. + */ + public Configurable withHttpClient(HttpClient httpClient) { + this.httpClient = Objects.requireNonNull(httpClient, "'httpClient' cannot be null."); + return this; + } + + /** + * Sets the logging options to the HTTP pipeline. + * + * @param httpLogOptions the HTTP log options. + * @return the configurable object itself. + */ + public Configurable withLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = Objects.requireNonNull(httpLogOptions, "'httpLogOptions' cannot be null."); + return this; + } + + /** + * Adds the pipeline policy to the HTTP pipeline. + * + * @param policy the HTTP pipeline policy. + * @return the configurable object itself. + */ + public Configurable withPolicy(HttpPipelinePolicy policy) { + this.policies.add(Objects.requireNonNull(policy, "'policy' cannot be null.")); + return this; + } + + /** + * Adds the scope to permission sets. + * + * @param scope the scope. + * @return the configurable object itself. + */ + public Configurable withScope(String scope) { + this.scopes.add(Objects.requireNonNull(scope, "'scope' cannot be null.")); + return this; + } + + /** + * Sets the retry policy to the HTTP pipeline. + * + * @param retryPolicy the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = Objects.requireNonNull(retryPolicy, "'retryPolicy' cannot be null."); + return this; + } + + /** + * Sets the retry options for the HTTP pipeline retry policy. + *

+ * This setting has no effect, if retry policy is set via {@link #withRetryPolicy(RetryPolicy)}. + * + * @param retryOptions the retry options for the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryOptions(RetryOptions retryOptions) { + this.retryOptions = Objects.requireNonNull(retryOptions, "'retryOptions' cannot be null."); + return this; + } + + /** + * Sets the default poll interval, used when service does not provide "Retry-After" header. + * + * @param defaultPollInterval the default poll interval. + * @return the configurable object itself. + */ + public Configurable withDefaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval + = Objects.requireNonNull(defaultPollInterval, "'defaultPollInterval' cannot be null."); + if (this.defaultPollInterval.isNegative()) { + throw LOGGER + .logExceptionAsError(new IllegalArgumentException("'defaultPollInterval' cannot be negative")); + } + return this; + } + + /** + * Creates an instance of ManagementGroup service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the ManagementGroup service API instance. + */ + public ManagementGroupManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + + String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); + + StringBuilder userAgentBuilder = new StringBuilder(); + userAgentBuilder.append("azsdk-java") + .append("-") + .append("azure.resourcemanager.managementgroup") + .append("/") + .append(clientVersion); + if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) { + userAgentBuilder.append(" (") + .append(Configuration.getGlobalConfiguration().get("java.version")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.name")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.version")) + .append("; auto-generated)"); + } else { + userAgentBuilder.append(" (auto-generated)"); + } + + if (scopes.isEmpty()) { + scopes.add(profile.getEnvironment().getManagementEndpoint() + "/.default"); + } + if (retryPolicy == null) { + if (retryOptions != null) { + retryPolicy = new RetryPolicy(retryOptions); + } else { + retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); + } + } + List policies = new ArrayList<>(); + policies.add(new UserAgentPolicy(userAgentBuilder.toString())); + policies.add(new AddHeadersFromContextPolicy()); + policies.add(new RequestIdPolicy()); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .collect(Collectors.toList())); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(retryPolicy); + policies.add(new AddDatePolicy()); + policies.add(new BearerTokenAuthenticationPolicy(credential, scopes.toArray(new String[0]))); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .collect(Collectors.toList())); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + HttpPipeline httpPipeline = new HttpPipelineBuilder().httpClient(httpClient) + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .build(); + return new ManagementGroupManager(httpPipeline, profile, defaultPollInterval); + } + } + + /** + * Gets the resource collection API of ManagementGroupChildResources. + * + * @return Resource collection API of ManagementGroupChildResources. + */ + public ManagementGroupChildResources managementGroupChildResources() { + if (this.managementGroupChildResources == null) { + this.managementGroupChildResources + = new ManagementGroupChildResourcesImpl(clientObject.getManagementGroupChildResources(), this); + } + return managementGroupChildResources; + } + + /** + * Gets wrapped service client ManagementGroupClient providing direct access to the underlying auto-generated API + * implementation, based on Azure REST API. + * + * @return Wrapped service client ManagementGroupClient. + */ + public ManagementGroupClient serviceClient() { + return this.clientObject; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/ManagementGroupChildResourcesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/ManagementGroupChildResourcesClient.java new file mode 100644 index 00000000000..ac559a3162c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/ManagementGroupChildResourcesClient.java @@ -0,0 +1,198 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.managementgroup.fluent; + +import azure.resourcemanager.managementgroup.fluent.models.ManagementGroupChildResourceInner; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.polling.SyncPoller; + +/** + * An instance of this class provides access to all the operations defined in ManagementGroupChildResourcesClient. + */ +public interface ManagementGroupChildResourcesClient { + /** + * Get a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ManagementGroupChildResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getWithResponse(String managementGroupId, + String managementGroupChildResourceName, Context context); + + /** + * Get a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ManagementGroupChildResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ManagementGroupChildResourceInner get(String managementGroupId, String managementGroupChildResourceName); + + /** + * Create a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of concrete extension resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, ManagementGroupChildResourceInner> beginCreateOrUpdate( + String managementGroupId, String managementGroupChildResourceName, ManagementGroupChildResourceInner resource); + + /** + * Create a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of concrete extension resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, ManagementGroupChildResourceInner> beginCreateOrUpdate( + String managementGroupId, String managementGroupChildResourceName, ManagementGroupChildResourceInner resource, + Context context); + + /** + * Create a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ManagementGroupChildResourceInner createOrUpdate(String managementGroupId, String managementGroupChildResourceName, + ManagementGroupChildResourceInner resource); + + /** + * Create a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ManagementGroupChildResourceInner createOrUpdate(String managementGroupId, String managementGroupChildResourceName, + ManagementGroupChildResourceInner resource, Context context); + + /** + * Update a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param properties The resource properties to be updated. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type + * along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response updateWithResponse(String managementGroupId, + String managementGroupChildResourceName, ManagementGroupChildResourceInner properties, Context context); + + /** + * Update a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ManagementGroupChildResourceInner update(String managementGroupId, String managementGroupChildResourceName, + ManagementGroupChildResourceInner properties); + + /** + * Delete a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response deleteWithResponse(String managementGroupId, String managementGroupChildResourceName, + Context context); + + /** + * Delete a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String managementGroupId, String managementGroupChildResourceName); + + /** + * List ManagementGroupChildResource resources by scope. + * + * @param managementGroupId The management group ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ManagementGroupChildResource list operation as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByManagementGroup(String managementGroupId); + + /** + * List ManagementGroupChildResource resources by scope. + * + * @param managementGroupId The management group ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ManagementGroupChildResource list operation as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByManagementGroup(String managementGroupId, Context context); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/ManagementGroupClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/ManagementGroupClient.java new file mode 100644 index 00000000000..e60ba06577a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/ManagementGroupClient.java @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.managementgroup.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** + * The interface for ManagementGroupClient class. + */ +public interface ManagementGroupClient { + /** + * Gets Service host. + * + * @return the endpoint value. + */ + String getEndpoint(); + + /** + * Gets Version parameter. + * + * @return the apiVersion value. + */ + String getApiVersion(); + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + HttpPipeline getHttpPipeline(); + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + Duration getDefaultPollInterval(); + + /** + * Gets the ManagementGroupChildResourcesClient object to access its operations. + * + * @return the ManagementGroupChildResourcesClient object. + */ + ManagementGroupChildResourcesClient getManagementGroupChildResources(); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/models/ManagementGroupChildResourceInner.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/models/ManagementGroupChildResourceInner.java new file mode 100644 index 00000000000..b87789de563 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/models/ManagementGroupChildResourceInner.java @@ -0,0 +1,157 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.managementgroup.fluent.models; + +import azure.resourcemanager.managementgroup.models.ManagementGroupChildResourceProperties; +import com.azure.core.annotation.Fluent; +import com.azure.core.management.ProxyResource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Concrete extension resource types can be created by aliasing this type using a specific property type. + */ +@Fluent +public final class ManagementGroupChildResourceInner extends ProxyResource { + /* + * The resource-specific properties for this resource. + */ + private ManagementGroupChildResourceProperties properties; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * The type of the resource. + */ + private String type; + + /* + * The name of the resource. + */ + private String name; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /** + * Creates an instance of ManagementGroupChildResourceInner class. + */ + public ManagementGroupChildResourceInner() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public ManagementGroupChildResourceProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the ManagementGroupChildResourceInner object itself. + */ + public ManagementGroupChildResourceInner withProperties(ManagementGroupChildResourceProperties properties) { + this.properties = properties; + return this; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("properties", this.properties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ManagementGroupChildResourceInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ManagementGroupChildResourceInner if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ManagementGroupChildResourceInner. + */ + public static ManagementGroupChildResourceInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ManagementGroupChildResourceInner deserializedManagementGroupChildResourceInner + = new ManagementGroupChildResourceInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedManagementGroupChildResourceInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedManagementGroupChildResourceInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedManagementGroupChildResourceInner.type = reader.getString(); + } else if ("properties".equals(fieldName)) { + deserializedManagementGroupChildResourceInner.properties + = ManagementGroupChildResourceProperties.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedManagementGroupChildResourceInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedManagementGroupChildResourceInner; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/models/package-info.java new file mode 100644 index 00000000000..7bc5661857f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/models/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the inner data models for ManagementGroup. + * Arm Resource Provider management API. + */ +package azure.resourcemanager.managementgroup.fluent.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/package-info.java new file mode 100644 index 00000000000..47cc28858f0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the service clients for ManagementGroup. + * Arm Resource Provider management API. + */ +package azure.resourcemanager.managementgroup.fluent; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupChildResourceImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupChildResourceImpl.java new file mode 100644 index 00000000000..8bcda8f0e70 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupChildResourceImpl.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.managementgroup.implementation; + +import azure.resourcemanager.managementgroup.fluent.models.ManagementGroupChildResourceInner; +import azure.resourcemanager.managementgroup.models.ManagementGroupChildResource; +import azure.resourcemanager.managementgroup.models.ManagementGroupChildResourceProperties; +import com.azure.core.management.SystemData; + +public final class ManagementGroupChildResourceImpl implements ManagementGroupChildResource { + private ManagementGroupChildResourceInner innerObject; + + private final azure.resourcemanager.managementgroup.ManagementGroupManager serviceManager; + + ManagementGroupChildResourceImpl(ManagementGroupChildResourceInner innerObject, + azure.resourcemanager.managementgroup.ManagementGroupManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public ManagementGroupChildResourceProperties properties() { + return this.innerModel().properties(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public ManagementGroupChildResourceInner innerModel() { + return this.innerObject; + } + + private azure.resourcemanager.managementgroup.ManagementGroupManager manager() { + return this.serviceManager; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupChildResourcesClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupChildResourcesClientImpl.java new file mode 100644 index 00000000000..4dc96f94473 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupChildResourcesClientImpl.java @@ -0,0 +1,758 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.managementgroup.implementation; + +import azure.resourcemanager.managementgroup.fluent.ManagementGroupChildResourcesClient; +import azure.resourcemanager.managementgroup.fluent.models.ManagementGroupChildResourceInner; +import azure.resourcemanager.managementgroup.implementation.models.ManagementGroupChildResourceListResult; +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Patch; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import java.nio.ByteBuffer; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in ManagementGroupChildResourcesClient. + */ +public final class ManagementGroupChildResourcesClientImpl implements ManagementGroupChildResourcesClient { + /** + * The proxy service used to perform REST calls. + */ + private final ManagementGroupChildResourcesService service; + + /** + * The service client containing this operation class. + */ + private final ManagementGroupClientImpl client; + + /** + * Initializes an instance of ManagementGroupChildResourcesClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ManagementGroupChildResourcesClientImpl(ManagementGroupClientImpl client) { + this.service = RestProxy.create(ManagementGroupChildResourcesService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ManagementGroupClientManagementGroupChildResources to be used by the + * proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ManagementGroupClientManagementGroupChildResources") + public interface ManagementGroupChildResourcesService { + @Headers({ "Content-Type: application/json" }) + @Get("/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.ManagementGroupChild/managementGroupChildResources/{managementGroupChildResourceName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> get(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("managementGroupId") String managementGroupId, + @PathParam("managementGroupChildResourceName") String managementGroupChildResourceName, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.ManagementGroupChild/managementGroupChildResources/{managementGroupChildResourceName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response getSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("managementGroupId") String managementGroupId, + @PathParam("managementGroupChildResourceName") String managementGroupChildResourceName, + @HeaderParam("Accept") String accept, Context context); + + @Put("/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.ManagementGroupChild/managementGroupChildResources/{managementGroupChildResourceName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> createOrUpdate(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("managementGroupId") String managementGroupId, + @PathParam("managementGroupChildResourceName") String managementGroupChildResourceName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") ManagementGroupChildResourceInner resource, Context context); + + @Put("/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.ManagementGroupChild/managementGroupChildResources/{managementGroupChildResourceName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response createOrUpdateSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("managementGroupId") String managementGroupId, + @PathParam("managementGroupChildResourceName") String managementGroupChildResourceName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") ManagementGroupChildResourceInner resource, Context context); + + @Patch("/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.ManagementGroupChild/managementGroupChildResources/{managementGroupChildResourceName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> update(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("managementGroupId") String managementGroupId, + @PathParam("managementGroupChildResourceName") String managementGroupChildResourceName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") ManagementGroupChildResourceInner properties, Context context); + + @Patch("/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.ManagementGroupChild/managementGroupChildResources/{managementGroupChildResourceName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response updateSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("managementGroupId") String managementGroupId, + @PathParam("managementGroupChildResourceName") String managementGroupChildResourceName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") ManagementGroupChildResourceInner properties, Context context); + + @Headers({ "Accept: application/json;q=0.9", "Content-Type: application/json" }) + @Delete("/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.ManagementGroupChild/managementGroupChildResources/{managementGroupChildResourceName}") + @ExpectedResponses({ 200, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> delete(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("managementGroupId") String managementGroupId, + @PathParam("managementGroupChildResourceName") String managementGroupChildResourceName, Context context); + + @Headers({ "Accept: application/json;q=0.9", "Content-Type: application/json" }) + @Delete("/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.ManagementGroupChild/managementGroupChildResources/{managementGroupChildResourceName}") + @ExpectedResponses({ 200, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response deleteSync(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, + @PathParam("managementGroupId") String managementGroupId, + @PathParam("managementGroupChildResourceName") String managementGroupChildResourceName, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.ManagementGroupChild/managementGroupChildResources") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByManagementGroup( + @HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, + @PathParam("managementGroupId") String managementGroupId, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.ManagementGroupChild/managementGroupChildResources") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response listByManagementGroupSync( + @HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, + @PathParam("managementGroupId") String managementGroupId, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByManagementGroupNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response listByManagementGroupNextSync( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, Context context); + } + + /** + * Get a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ManagementGroupChildResource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String managementGroupId, + String managementGroupChildResourceName) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.get(this.client.getEndpoint(), this.client.getApiVersion(), + managementGroupId, managementGroupChildResourceName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ManagementGroupChildResource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getAsync(String managementGroupId, + String managementGroupChildResourceName) { + return getWithResponseAsync(managementGroupId, managementGroupChildResourceName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ManagementGroupChildResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String managementGroupId, + String managementGroupChildResourceName, Context context) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), this.client.getApiVersion(), managementGroupId, + managementGroupChildResourceName, accept, context); + } + + /** + * Get a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ManagementGroupChildResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ManagementGroupChildResourceInner get(String managementGroupId, String managementGroupChildResourceName) { + return getWithResponse(managementGroupId, managementGroupChildResourceName, Context.NONE).getValue(); + } + + /** + * Create a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type + * along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrUpdateWithResponseAsync(String managementGroupId, + String managementGroupChildResourceName, ManagementGroupChildResourceInner resource) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + managementGroupId, managementGroupChildResourceName, contentType, accept, resource, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type + * along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response createOrUpdateWithResponse(String managementGroupId, + String managementGroupChildResourceName, ManagementGroupChildResourceInner resource) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createOrUpdateSync(this.client.getEndpoint(), this.client.getApiVersion(), managementGroupId, + managementGroupChildResourceName, contentType, accept, resource, Context.NONE); + } + + /** + * Create a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type + * along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response createOrUpdateWithResponse(String managementGroupId, + String managementGroupChildResourceName, ManagementGroupChildResourceInner resource, Context context) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createOrUpdateSync(this.client.getEndpoint(), this.client.getApiVersion(), managementGroupId, + managementGroupChildResourceName, contentType, accept, resource, context); + } + + /** + * Create a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of concrete extension resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, ManagementGroupChildResourceInner> + beginCreateOrUpdateAsync(String managementGroupId, String managementGroupChildResourceName, + ManagementGroupChildResourceInner resource) { + Mono>> mono + = createOrUpdateWithResponseAsync(managementGroupId, managementGroupChildResourceName, resource); + return this.client.getLroResult(mono, + this.client.getHttpPipeline(), ManagementGroupChildResourceInner.class, + ManagementGroupChildResourceInner.class, this.client.getContext()); + } + + /** + * Create a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of concrete extension resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, ManagementGroupChildResourceInner> + beginCreateOrUpdate(String managementGroupId, String managementGroupChildResourceName, + ManagementGroupChildResourceInner resource) { + Response response + = createOrUpdateWithResponse(managementGroupId, managementGroupChildResourceName, resource); + return this.client.getLroResult(response, + ManagementGroupChildResourceInner.class, ManagementGroupChildResourceInner.class, Context.NONE); + } + + /** + * Create a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of concrete extension resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, ManagementGroupChildResourceInner> + beginCreateOrUpdate(String managementGroupId, String managementGroupChildResourceName, + ManagementGroupChildResourceInner resource, Context context) { + Response response + = createOrUpdateWithResponse(managementGroupId, managementGroupChildResourceName, resource, context); + return this.client.getLroResult(response, + ManagementGroupChildResourceInner.class, ManagementGroupChildResourceInner.class, context); + } + + /** + * Create a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String managementGroupId, + String managementGroupChildResourceName, ManagementGroupChildResourceInner resource) { + return beginCreateOrUpdateAsync(managementGroupId, managementGroupChildResourceName, resource).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ManagementGroupChildResourceInner createOrUpdate(String managementGroupId, + String managementGroupChildResourceName, ManagementGroupChildResourceInner resource) { + return beginCreateOrUpdate(managementGroupId, managementGroupChildResourceName, resource).getFinalResult(); + } + + /** + * Create a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ManagementGroupChildResourceInner createOrUpdate(String managementGroupId, + String managementGroupChildResourceName, ManagementGroupChildResourceInner resource, Context context) { + return beginCreateOrUpdate(managementGroupId, managementGroupChildResourceName, resource, context) + .getFinalResult(); + } + + /** + * Update a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type + * along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync(String managementGroupId, + String managementGroupChildResourceName, ManagementGroupChildResourceInner properties) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.update(this.client.getEndpoint(), this.client.getApiVersion(), + managementGroupId, managementGroupChildResourceName, contentType, accept, properties, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Update a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync(String managementGroupId, + String managementGroupChildResourceName, ManagementGroupChildResourceInner properties) { + return updateWithResponseAsync(managementGroupId, managementGroupChildResourceName, properties) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Update a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param properties The resource properties to be updated. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type + * along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateWithResponse(String managementGroupId, + String managementGroupChildResourceName, ManagementGroupChildResourceInner properties, Context context) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.updateSync(this.client.getEndpoint(), this.client.getApiVersion(), managementGroupId, + managementGroupChildResourceName, contentType, accept, properties, context); + } + + /** + * Update a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ManagementGroupChildResourceInner update(String managementGroupId, String managementGroupChildResourceName, + ManagementGroupChildResourceInner properties) { + return updateWithResponse(managementGroupId, managementGroupChildResourceName, properties, Context.NONE) + .getValue(); + } + + /** + * Delete a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync(String managementGroupId, + String managementGroupChildResourceName) { + return FluxUtil + .withContext(context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(), + managementGroupId, managementGroupChildResourceName, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String managementGroupId, String managementGroupChildResourceName) { + return deleteWithResponseAsync(managementGroupId, managementGroupChildResourceName) + .flatMap(ignored -> Mono.empty()); + } + + /** + * Delete a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteWithResponse(String managementGroupId, String managementGroupChildResourceName, + Context context) { + return service.deleteSync(this.client.getEndpoint(), this.client.getApiVersion(), managementGroupId, + managementGroupChildResourceName, context); + } + + /** + * Delete a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String managementGroupId, String managementGroupChildResourceName) { + deleteWithResponse(managementGroupId, managementGroupChildResourceName, Context.NONE); + } + + /** + * List ManagementGroupChildResource resources by scope. + * + * @param managementGroupId The management group ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ManagementGroupChildResource list operation along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + listByManagementGroupSinglePageAsync(String managementGroupId) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByManagementGroup(this.client.getEndpoint(), + this.client.getApiVersion(), managementGroupId, accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * List ManagementGroupChildResource resources by scope. + * + * @param managementGroupId The management group ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ManagementGroupChildResource list operation as paginated response with + * {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByManagementGroupAsync(String managementGroupId) { + return new PagedFlux<>(() -> listByManagementGroupSinglePageAsync(managementGroupId), + nextLink -> listByManagementGroupNextSinglePageAsync(nextLink)); + } + + /** + * List ManagementGroupChildResource resources by scope. + * + * @param managementGroupId The management group ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ManagementGroupChildResource list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listByManagementGroupSinglePage(String managementGroupId) { + final String accept = "application/json"; + Response res = service.listByManagementGroupSync( + this.client.getEndpoint(), this.client.getApiVersion(), managementGroupId, accept, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + /** + * List ManagementGroupChildResource resources by scope. + * + * @param managementGroupId The management group ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ManagementGroupChildResource list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listByManagementGroupSinglePage(String managementGroupId, + Context context) { + final String accept = "application/json"; + Response res = service.listByManagementGroupSync( + this.client.getEndpoint(), this.client.getApiVersion(), managementGroupId, accept, context); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + /** + * List ManagementGroupChildResource resources by scope. + * + * @param managementGroupId The management group ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ManagementGroupChildResource list operation as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByManagementGroup(String managementGroupId) { + return new PagedIterable<>(() -> listByManagementGroupSinglePage(managementGroupId), + nextLink -> listByManagementGroupNextSinglePage(nextLink)); + } + + /** + * List ManagementGroupChildResource resources by scope. + * + * @param managementGroupId The management group ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ManagementGroupChildResource list operation as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByManagementGroup(String managementGroupId, + Context context) { + return new PagedIterable<>(() -> listByManagementGroupSinglePage(managementGroupId, context), + nextLink -> listByManagementGroupNextSinglePage(nextLink, context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ManagementGroupChildResource list operation along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + listByManagementGroupNextSinglePageAsync(String nextLink) { + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listByManagementGroupNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ManagementGroupChildResource list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listByManagementGroupNextSinglePage(String nextLink) { + final String accept = "application/json"; + Response res + = service.listByManagementGroupNextSync(nextLink, this.client.getEndpoint(), accept, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ManagementGroupChildResource list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listByManagementGroupNextSinglePage(String nextLink, + Context context) { + final String accept = "application/json"; + Response res + = service.listByManagementGroupNextSync(nextLink, this.client.getEndpoint(), accept, context); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupChildResourcesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupChildResourcesImpl.java new file mode 100644 index 00000000000..1b38a9f706c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupChildResourcesImpl.java @@ -0,0 +1,120 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.managementgroup.implementation; + +import azure.resourcemanager.managementgroup.fluent.ManagementGroupChildResourcesClient; +import azure.resourcemanager.managementgroup.fluent.models.ManagementGroupChildResourceInner; +import azure.resourcemanager.managementgroup.models.ManagementGroupChildResource; +import azure.resourcemanager.managementgroup.models.ManagementGroupChildResources; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; + +public final class ManagementGroupChildResourcesImpl implements ManagementGroupChildResources { + private static final ClientLogger LOGGER = new ClientLogger(ManagementGroupChildResourcesImpl.class); + + private final ManagementGroupChildResourcesClient innerClient; + + private final azure.resourcemanager.managementgroup.ManagementGroupManager serviceManager; + + public ManagementGroupChildResourcesImpl(ManagementGroupChildResourcesClient innerClient, + azure.resourcemanager.managementgroup.ManagementGroupManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getWithResponse(String managementGroupId, + String managementGroupChildResourceName, Context context) { + Response inner + = this.serviceClient().getWithResponse(managementGroupId, managementGroupChildResourceName, context); + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new ManagementGroupChildResourceImpl(inner.getValue(), this.manager())); + } + + public ManagementGroupChildResource get(String managementGroupId, String managementGroupChildResourceName) { + ManagementGroupChildResourceInner inner + = this.serviceClient().get(managementGroupId, managementGroupChildResourceName); + if (inner != null) { + return new ManagementGroupChildResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public ManagementGroupChildResource createOrUpdate(String managementGroupId, + String managementGroupChildResourceName, ManagementGroupChildResourceInner resource) { + ManagementGroupChildResourceInner inner + = this.serviceClient().createOrUpdate(managementGroupId, managementGroupChildResourceName, resource); + if (inner != null) { + return new ManagementGroupChildResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public ManagementGroupChildResource createOrUpdate(String managementGroupId, + String managementGroupChildResourceName, ManagementGroupChildResourceInner resource, Context context) { + ManagementGroupChildResourceInner inner = this.serviceClient() + .createOrUpdate(managementGroupId, managementGroupChildResourceName, resource, context); + if (inner != null) { + return new ManagementGroupChildResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response updateWithResponse(String managementGroupId, + String managementGroupChildResourceName, ManagementGroupChildResourceInner properties, Context context) { + Response inner = this.serviceClient() + .updateWithResponse(managementGroupId, managementGroupChildResourceName, properties, context); + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new ManagementGroupChildResourceImpl(inner.getValue(), this.manager())); + } + + public ManagementGroupChildResource update(String managementGroupId, String managementGroupChildResourceName, + ManagementGroupChildResourceInner properties) { + ManagementGroupChildResourceInner inner + = this.serviceClient().update(managementGroupId, managementGroupChildResourceName, properties); + if (inner != null) { + return new ManagementGroupChildResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response deleteByResourceGroupWithResponse(String managementGroupId, + String managementGroupChildResourceName, Context context) { + return this.serviceClient().deleteWithResponse(managementGroupId, managementGroupChildResourceName, context); + } + + public void deleteByResourceGroup(String managementGroupId, String managementGroupChildResourceName) { + this.serviceClient().delete(managementGroupId, managementGroupChildResourceName); + } + + public PagedIterable listByManagementGroup(String managementGroupId) { + PagedIterable inner + = this.serviceClient().listByManagementGroup(managementGroupId); + return ResourceManagerUtils.mapPage(inner, + inner1 -> new ManagementGroupChildResourceImpl(inner1, this.manager())); + } + + public PagedIterable listByManagementGroup(String managementGroupId, + Context context) { + PagedIterable inner + = this.serviceClient().listByManagementGroup(managementGroupId, context); + return ResourceManagerUtils.mapPage(inner, + inner1 -> new ManagementGroupChildResourceImpl(inner1, this.manager())); + } + + private ManagementGroupChildResourcesClient serviceClient() { + return this.innerClient; + } + + private azure.resourcemanager.managementgroup.ManagementGroupManager manager() { + return this.serviceManager; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupClientBuilder.java new file mode 100644 index 00000000000..9a5147e1909 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupClientBuilder.java @@ -0,0 +1,122 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.managementgroup.implementation; + +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerAdapter; +import java.time.Duration; + +/** + * A builder for creating a new instance of the ManagementGroupClientImpl type. + */ +@ServiceClientBuilder(serviceClients = { ManagementGroupClientImpl.class }) +public final class ManagementGroupClientBuilder { + /* + * Service host + */ + private String endpoint; + + /** + * Sets Service host. + * + * @param endpoint the endpoint value. + * @return the ManagementGroupClientBuilder. + */ + public ManagementGroupClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * The environment to connect to + */ + private AzureEnvironment environment; + + /** + * Sets The environment to connect to. + * + * @param environment the environment value. + * @return the ManagementGroupClientBuilder. + */ + public ManagementGroupClientBuilder environment(AzureEnvironment environment) { + this.environment = environment; + return this; + } + + /* + * The HTTP pipeline to send requests through + */ + private HttpPipeline pipeline; + + /** + * Sets The HTTP pipeline to send requests through. + * + * @param pipeline the pipeline value. + * @return the ManagementGroupClientBuilder. + */ + public ManagementGroupClientBuilder pipeline(HttpPipeline pipeline) { + this.pipeline = pipeline; + return this; + } + + /* + * The default poll interval for long-running operation + */ + private Duration defaultPollInterval; + + /** + * Sets The default poll interval for long-running operation. + * + * @param defaultPollInterval the defaultPollInterval value. + * @return the ManagementGroupClientBuilder. + */ + public ManagementGroupClientBuilder defaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval = defaultPollInterval; + return this; + } + + /* + * The serializer to serialize an object into a string + */ + private SerializerAdapter serializerAdapter; + + /** + * Sets The serializer to serialize an object into a string. + * + * @param serializerAdapter the serializerAdapter value. + * @return the ManagementGroupClientBuilder. + */ + public ManagementGroupClientBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of ManagementGroupClientImpl with the provided parameters. + * + * @return an instance of ManagementGroupClientImpl. + */ + public ManagementGroupClientImpl buildClient() { + String localEndpoint = (endpoint != null) ? endpoint : "https://management.azure.com"; + AzureEnvironment localEnvironment = (environment != null) ? environment : AzureEnvironment.AZURE; + HttpPipeline localPipeline = (pipeline != null) + ? pipeline + : new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(); + Duration localDefaultPollInterval + = (defaultPollInterval != null) ? defaultPollInterval : Duration.ofSeconds(30); + SerializerAdapter localSerializerAdapter = (serializerAdapter != null) + ? serializerAdapter + : SerializerFactory.createDefaultManagementSerializerAdapter(); + ManagementGroupClientImpl client = new ManagementGroupClientImpl(localPipeline, localSerializerAdapter, + localDefaultPollInterval, localEnvironment, localEndpoint); + return client; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupClientImpl.java new file mode 100644 index 00000000000..839fee59369 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupClientImpl.java @@ -0,0 +1,292 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.managementgroup.implementation; + +import azure.resourcemanager.managementgroup.fluent.ManagementGroupChildResourcesClient; +import azure.resourcemanager.managementgroup.fluent.ManagementGroupClient; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpResponse; +import com.azure.core.http.rest.Response; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.exception.ManagementError; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.management.polling.PollerFactory; +import com.azure.core.management.polling.SyncPollerFactory; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.AsyncPollResponse; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.SerializerEncoding; +import java.io.IOException; +import java.lang.reflect.Type; +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.time.Duration; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the ManagementGroupClientImpl type. + */ +@ServiceClient(builder = ManagementGroupClientBuilder.class) +public final class ManagementGroupClientImpl implements ManagementGroupClient { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Version parameter. + */ + private final String apiVersion; + + /** + * Gets Version parameter. + * + * @return the apiVersion value. + */ + public String getApiVersion() { + return this.apiVersion; + } + + /** + * The HTTP pipeline to send requests through. + */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** + * The serializer to serialize an object into a string. + */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** + * The default poll interval for long-running operation. + */ + private final Duration defaultPollInterval; + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + public Duration getDefaultPollInterval() { + return this.defaultPollInterval; + } + + /** + * The ManagementGroupChildResourcesClient object to access its operations. + */ + private final ManagementGroupChildResourcesClient managementGroupChildResources; + + /** + * Gets the ManagementGroupChildResourcesClient object to access its operations. + * + * @return the ManagementGroupChildResourcesClient object. + */ + public ManagementGroupChildResourcesClient getManagementGroupChildResources() { + return this.managementGroupChildResources; + } + + /** + * Initializes an instance of ManagementGroupClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param defaultPollInterval The default poll interval for long-running operation. + * @param environment The Azure environment. + * @param endpoint Service host. + */ + ManagementGroupClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + Duration defaultPollInterval, AzureEnvironment environment, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.endpoint = endpoint; + this.apiVersion = "2023-12-01-preview"; + this.managementGroupChildResources = new ManagementGroupChildResourcesClientImpl(this); + } + + /** + * Gets default client context. + * + * @return the default client context. + */ + public Context getContext() { + return Context.NONE; + } + + /** + * Merges default client context with provided context. + * + * @param context the context to be merged with default client context. + * @return the merged context. + */ + public Context mergeContext(Context context) { + return CoreUtils.mergeContexts(this.getContext(), context); + } + + /** + * Gets long running operation result. + * + * @param activationResponse the response of activation operation. + * @param httpPipeline the http pipeline. + * @param pollResultType type of poll result. + * @param finalResultType type of final result. + * @param context the context shared by all requests. + * @param type of poll result. + * @param type of final result. + * @return poller flux for poll result and final result. + */ + public PollerFlux, U> getLroResult(Mono>> activationResponse, + HttpPipeline httpPipeline, Type pollResultType, Type finalResultType, Context context) { + return PollerFactory.create(serializerAdapter, httpPipeline, pollResultType, finalResultType, + defaultPollInterval, activationResponse, context); + } + + /** + * Gets long running operation result. + * + * @param activationResponse the response of activation operation. + * @param pollResultType type of poll result. + * @param finalResultType type of final result. + * @param context the context shared by all requests. + * @param type of poll result. + * @param type of final result. + * @return SyncPoller for poll result and final result. + */ + public SyncPoller, U> getLroResult(Response activationResponse, + Type pollResultType, Type finalResultType, Context context) { + return SyncPollerFactory.create(serializerAdapter, httpPipeline, pollResultType, finalResultType, + defaultPollInterval, () -> activationResponse, context); + } + + /** + * Gets the final result, or an error, based on last async poll response. + * + * @param response the last async poll response. + * @param type of poll result. + * @param type of final result. + * @return the final result, or an error. + */ + public Mono getLroFinalResultOrError(AsyncPollResponse, U> response) { + if (response.getStatus() != LongRunningOperationStatus.SUCCESSFULLY_COMPLETED) { + String errorMessage; + ManagementError managementError = null; + HttpResponse errorResponse = null; + PollResult.Error lroError = response.getValue().getError(); + if (lroError != null) { + errorResponse = new HttpResponseImpl(lroError.getResponseStatusCode(), lroError.getResponseHeaders(), + lroError.getResponseBody()); + + errorMessage = response.getValue().getError().getMessage(); + String errorBody = response.getValue().getError().getResponseBody(); + if (errorBody != null) { + // try to deserialize error body to ManagementError + try { + managementError = this.getSerializerAdapter() + .deserialize(errorBody, ManagementError.class, SerializerEncoding.JSON); + if (managementError.getCode() == null || managementError.getMessage() == null) { + managementError = null; + } + } catch (IOException | RuntimeException ioe) { + LOGGER.logThrowableAsWarning(ioe); + } + } + } else { + // fallback to default error message + errorMessage = "Long running operation failed."; + } + if (managementError == null) { + // fallback to default ManagementError + managementError = new ManagementError(response.getStatus().toString(), errorMessage); + } + return Mono.error(new ManagementException(errorMessage, errorResponse, managementError)); + } else { + return response.getFinalResult(); + } + } + + private static final class HttpResponseImpl extends HttpResponse { + private final int statusCode; + + private final byte[] responseBody; + + private final HttpHeaders httpHeaders; + + HttpResponseImpl(int statusCode, HttpHeaders httpHeaders, String responseBody) { + super(null); + this.statusCode = statusCode; + this.httpHeaders = httpHeaders; + this.responseBody = responseBody == null ? null : responseBody.getBytes(StandardCharsets.UTF_8); + } + + public int getStatusCode() { + return statusCode; + } + + public String getHeaderValue(String s) { + return httpHeaders.getValue(HttpHeaderName.fromString(s)); + } + + public HttpHeaders getHeaders() { + return httpHeaders; + } + + public Flux getBody() { + return Flux.just(ByteBuffer.wrap(responseBody)); + } + + public Mono getBodyAsByteArray() { + return Mono.just(responseBody); + } + + public Mono getBodyAsString() { + return Mono.just(new String(responseBody, StandardCharsets.UTF_8)); + } + + public Mono getBodyAsString(Charset charset) { + return Mono.just(new String(responseBody, charset)); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(ManagementGroupClientImpl.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ResourceManagerUtils.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ResourceManagerUtils.java new file mode 100644 index 00000000000..1734d5cff5b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ResourceManagerUtils.java @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.managementgroup.implementation; + +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.util.CoreUtils; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import reactor.core.publisher.Flux; + +final class ResourceManagerUtils { + private ResourceManagerUtils() { + } + + static String getValueFromIdByName(String id, String name) { + if (id == null) { + return null; + } + Iterator itr = Arrays.stream(id.split("/")).iterator(); + while (itr.hasNext()) { + String part = itr.next(); + if (part != null && !part.trim().isEmpty()) { + if (part.equalsIgnoreCase(name)) { + if (itr.hasNext()) { + return itr.next(); + } else { + return null; + } + } + } + } + return null; + } + + static String getValueFromIdByParameterName(String id, String pathTemplate, String parameterName) { + if (id == null || pathTemplate == null) { + return null; + } + String parameterNameParentheses = "{" + parameterName + "}"; + List idSegmentsReverted = Arrays.asList(id.split("/")); + List pathSegments = Arrays.asList(pathTemplate.split("/")); + Collections.reverse(idSegmentsReverted); + Iterator idItrReverted = idSegmentsReverted.iterator(); + int pathIndex = pathSegments.size(); + while (idItrReverted.hasNext() && pathIndex > 0) { + String idSegment = idItrReverted.next(); + String pathSegment = pathSegments.get(--pathIndex); + if (!CoreUtils.isNullOrEmpty(idSegment) && !CoreUtils.isNullOrEmpty(pathSegment)) { + if (pathSegment.equalsIgnoreCase(parameterNameParentheses)) { + if (pathIndex == 0 || (pathIndex == 1 && pathSegments.get(0).isEmpty())) { + List segments = new ArrayList<>(); + segments.add(idSegment); + idItrReverted.forEachRemaining(segments::add); + Collections.reverse(segments); + if (!segments.isEmpty() && segments.get(0).isEmpty()) { + segments.remove(0); + } + return String.join("/", segments); + } else { + return idSegment; + } + } + } + } + return null; + } + + static PagedIterable mapPage(PagedIterable pageIterable, Function mapper) { + return new PagedIterableImpl<>(pageIterable, mapper); + } + + private static final class PagedIterableImpl extends PagedIterable { + + private final PagedIterable pagedIterable; + private final Function mapper; + private final Function, PagedResponse> pageMapper; + + private PagedIterableImpl(PagedIterable pagedIterable, Function mapper) { + super(PagedFlux.create(() -> (continuationToken, pageSize) -> Flux + .fromStream(pagedIterable.streamByPage().map(getPageMapper(mapper))))); + this.pagedIterable = pagedIterable; + this.mapper = mapper; + this.pageMapper = getPageMapper(mapper); + } + + private static Function, PagedResponse> getPageMapper(Function mapper) { + return page -> new PagedResponseBase(page.getRequest(), page.getStatusCode(), page.getHeaders(), + page.getElements().stream().map(mapper).collect(Collectors.toList()), page.getContinuationToken(), + null); + } + + @Override + public Stream stream() { + return pagedIterable.stream().map(mapper); + } + + @Override + public Stream> streamByPage() { + return pagedIterable.streamByPage().map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken) { + return pagedIterable.streamByPage(continuationToken).map(pageMapper); + } + + @Override + public Stream> streamByPage(int preferredPageSize) { + return pagedIterable.streamByPage(preferredPageSize).map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken, int preferredPageSize) { + return pagedIterable.streamByPage(continuationToken, preferredPageSize).map(pageMapper); + } + + @Override + public Iterator iterator() { + return new IteratorImpl<>(pagedIterable.iterator(), mapper); + } + + @Override + public Iterable> iterableByPage() { + return new IterableImpl<>(pagedIterable.iterableByPage(), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken) { + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken), pageMapper); + } + + @Override + public Iterable> iterableByPage(int preferredPageSize) { + return new IterableImpl<>(pagedIterable.iterableByPage(preferredPageSize), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken, int preferredPageSize) { + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken, preferredPageSize), pageMapper); + } + } + + private static final class IteratorImpl implements Iterator { + + private final Iterator iterator; + private final Function mapper; + + private IteratorImpl(Iterator iterator, Function mapper) { + this.iterator = iterator; + this.mapper = mapper; + } + + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public S next() { + return mapper.apply(iterator.next()); + } + + @Override + public void remove() { + iterator.remove(); + } + } + + private static final class IterableImpl implements Iterable { + + private final Iterable iterable; + private final Function mapper; + + private IterableImpl(Iterable iterable, Function mapper) { + this.iterable = iterable; + this.mapper = mapper; + } + + @Override + public Iterator iterator() { + return new IteratorImpl<>(iterable.iterator(), mapper); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/models/ManagementGroupChildResourceListResult.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/models/ManagementGroupChildResourceListResult.java new file mode 100644 index 00000000000..7aa4fba8867 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/models/ManagementGroupChildResourceListResult.java @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.managementgroup.implementation.models; + +import azure.resourcemanager.managementgroup.fluent.models.ManagementGroupChildResourceInner; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * The response of a ManagementGroupChildResource list operation. + */ +@Immutable +public final class ManagementGroupChildResourceListResult + implements JsonSerializable { + /* + * The ManagementGroupChildResource items on this page + */ + private List value; + + /* + * The link to the next page of items + */ + private String nextLink; + + /** + * Creates an instance of ManagementGroupChildResourceListResult class. + */ + private ManagementGroupChildResourceListResult() { + } + + /** + * Get the value property: The ManagementGroupChildResource items on this page. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Get the nextLink property: The link to the next page of items. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("nextLink", this.nextLink); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ManagementGroupChildResourceListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ManagementGroupChildResourceListResult if the JsonReader was pointing to an instance of + * it, or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ManagementGroupChildResourceListResult. + */ + public static ManagementGroupChildResourceListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ManagementGroupChildResourceListResult deserializedManagementGroupChildResourceListResult + = new ManagementGroupChildResourceListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value + = reader.readArray(reader1 -> ManagementGroupChildResourceInner.fromJson(reader1)); + deserializedManagementGroupChildResourceListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedManagementGroupChildResourceListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedManagementGroupChildResourceListResult; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/package-info.java new file mode 100644 index 00000000000..764c7e548c4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for ManagementGroup. + * Arm Resource Provider management API. + */ +package azure.resourcemanager.managementgroup.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/ManagementGroupChildResource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/ManagementGroupChildResource.java new file mode 100644 index 00000000000..ce62d50d58e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/ManagementGroupChildResource.java @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.managementgroup.models; + +import azure.resourcemanager.managementgroup.fluent.models.ManagementGroupChildResourceInner; +import com.azure.core.management.SystemData; + +/** + * An immutable client-side representation of ManagementGroupChildResource. + */ +public interface ManagementGroupChildResource { + /** + * Gets the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: The name of the resource. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: The type of the resource. + * + * @return the type value. + */ + String type(); + + /** + * Gets the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + ManagementGroupChildResourceProperties properties(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the inner azure.resourcemanager.managementgroup.fluent.models.ManagementGroupChildResourceInner object. + * + * @return the inner object. + */ + ManagementGroupChildResourceInner innerModel(); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/ManagementGroupChildResourceProperties.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/ManagementGroupChildResourceProperties.java new file mode 100644 index 00000000000..a2cea68fedf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/ManagementGroupChildResourceProperties.java @@ -0,0 +1,104 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.managementgroup.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * ManagementGroupChildResource properties. + */ +@Fluent +public final class ManagementGroupChildResourceProperties + implements JsonSerializable { + /* + * The description of the resource. + */ + private String description; + + /* + * The status of the last operation. + */ + private ProvisioningState provisioningState; + + /** + * Creates an instance of ManagementGroupChildResourceProperties class. + */ + public ManagementGroupChildResourceProperties() { + } + + /** + * Get the description property: The description of the resource. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Set the description property: The description of the resource. + * + * @param description the description value to set. + * @return the ManagementGroupChildResourceProperties object itself. + */ + public ManagementGroupChildResourceProperties withDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the provisioningState property: The status of the last operation. + * + * @return the provisioningState value. + */ + public ProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("description", this.description); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ManagementGroupChildResourceProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ManagementGroupChildResourceProperties if the JsonReader was pointing to an instance of + * it, or null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the ManagementGroupChildResourceProperties. + */ + public static ManagementGroupChildResourceProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ManagementGroupChildResourceProperties deserializedManagementGroupChildResourceProperties + = new ManagementGroupChildResourceProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("description".equals(fieldName)) { + deserializedManagementGroupChildResourceProperties.description = reader.getString(); + } else if ("provisioningState".equals(fieldName)) { + deserializedManagementGroupChildResourceProperties.provisioningState + = ProvisioningState.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedManagementGroupChildResourceProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/ManagementGroupChildResources.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/ManagementGroupChildResources.java new file mode 100644 index 00000000000..6af24b87f65 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/ManagementGroupChildResources.java @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.managementgroup.models; + +import azure.resourcemanager.managementgroup.fluent.models.ManagementGroupChildResourceInner; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** + * Resource collection API of ManagementGroupChildResources. + */ +public interface ManagementGroupChildResources { + /** + * Get a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ManagementGroupChildResource along with {@link Response}. + */ + Response getWithResponse(String managementGroupId, + String managementGroupChildResourceName, Context context); + + /** + * Get a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ManagementGroupChildResource. + */ + ManagementGroupChildResource get(String managementGroupId, String managementGroupChildResourceName); + + /** + * Create a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type. + */ + ManagementGroupChildResource createOrUpdate(String managementGroupId, String managementGroupChildResourceName, + ManagementGroupChildResourceInner resource); + + /** + * Create a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type. + */ + ManagementGroupChildResource createOrUpdate(String managementGroupId, String managementGroupChildResourceName, + ManagementGroupChildResourceInner resource, Context context); + + /** + * Update a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param properties The resource properties to be updated. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type + * along with {@link Response}. + */ + Response updateWithResponse(String managementGroupId, + String managementGroupChildResourceName, ManagementGroupChildResourceInner properties, Context context); + + /** + * Update a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type. + */ + ManagementGroupChildResource update(String managementGroupId, String managementGroupChildResourceName, + ManagementGroupChildResourceInner properties); + + /** + * Delete a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response deleteByResourceGroupWithResponse(String managementGroupId, String managementGroupChildResourceName, + Context context); + + /** + * Delete a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteByResourceGroup(String managementGroupId, String managementGroupChildResourceName); + + /** + * List ManagementGroupChildResource resources by scope. + * + * @param managementGroupId The management group ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ManagementGroupChildResource list operation as paginated response with + * {@link PagedIterable}. + */ + PagedIterable listByManagementGroup(String managementGroupId); + + /** + * List ManagementGroupChildResource resources by scope. + * + * @param managementGroupId The management group ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ManagementGroupChildResource list operation as paginated response with + * {@link PagedIterable}. + */ + PagedIterable listByManagementGroup(String managementGroupId, Context context); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/ProvisioningState.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/ProvisioningState.java new file mode 100644 index 00000000000..879ae78b6d1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/ProvisioningState.java @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.managementgroup.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines values for ProvisioningState. + */ +public final class ProvisioningState extends ExpandableStringEnum { + /** + * Resource has been created. + */ + public static final ProvisioningState SUCCEEDED = fromString("Succeeded"); + + /** + * Resource creation failed. + */ + public static final ProvisioningState FAILED = fromString("Failed"); + + /** + * Resource creation was canceled. + */ + public static final ProvisioningState CANCELED = fromString("Canceled"); + + /** + * Static value Provisioning for ProvisioningState. + */ + public static final ProvisioningState PROVISIONING = fromString("Provisioning"); + + /** + * Static value Updating for ProvisioningState. + */ + public static final ProvisioningState UPDATING = fromString("Updating"); + + /** + * Static value Deleting for ProvisioningState. + */ + public static final ProvisioningState DELETING = fromString("Deleting"); + + /** + * Static value Accepted for ProvisioningState. + */ + public static final ProvisioningState ACCEPTED = fromString("Accepted"); + + /** + * Creates a new instance of ProvisioningState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ProvisioningState() { + } + + /** + * Creates or finds a ProvisioningState from its string representation. + * + * @param name a name to look for. + * @return the corresponding ProvisioningState. + */ + public static ProvisioningState fromString(String name) { + return fromString(name, ProvisioningState.class); + } + + /** + * Gets known ProvisioningState values. + * + * @return known ProvisioningState values. + */ + public static Collection values() { + return values(ProvisioningState.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/package-info.java new file mode 100644 index 00000000000..ea12c2867d7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the data models for ManagementGroup. + * Arm Resource Provider management API. + */ +package azure.resourcemanager.managementgroup.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/package-info.java new file mode 100644 index 00000000000..ed4ca36ee66 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for ManagementGroup. + * Arm Resource Provider management API. + */ +package azure.resourcemanager.managementgroup; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/BodyRootAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/BodyRootAsyncClient.java new file mode 100644 index 00000000000..473ea7fc80f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/BodyRootAsyncClient.java @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.bodyroot; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.FluxUtil; +import parameters.bodyroot.implementation.BodyRootClientImpl; +import parameters.bodyroot.models.BodyRootModel; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous BodyRootClient type. + */ +@ServiceClient(builder = BodyRootClientBuilder.class, isAsync = true) +public final class BodyRootAsyncClient { + @Generated + private final BodyRootClientImpl serviceClient; + + /** + * Initializes an instance of BodyRootAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BodyRootAsyncClient(BodyRootClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The nested operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     category: String (Optional)
+     *     linkType: String (Optional)
+     *     wasSuccessful: Boolean (Optional)
+     * }
+     * }
+     * 
+ * + * @param bodyRootParameters The bodyRootParameters parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> nestedWithResponse(BinaryData bodyRootParameters, RequestOptions requestOptions) { + return this.serviceClient.nestedWithResponseAsync(bodyRootParameters, requestOptions); + } + + /** + * The nested operation. + * + * @param bodyRootParameters The bodyRootParameters parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono nested(BodyRootModel bodyRootParameters) { + // Generated convenience method for nestedWithResponse + RequestOptions requestOptions = new RequestOptions(); + return nestedWithResponse(BinaryData.fromObject(bodyRootParameters), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/BodyRootClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/BodyRootClient.java new file mode 100644 index 00000000000..70be9e5e742 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/BodyRootClient.java @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.bodyroot; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import parameters.bodyroot.implementation.BodyRootClientImpl; +import parameters.bodyroot.models.BodyRootModel; + +/** + * Initializes a new instance of the synchronous BodyRootClient type. + */ +@ServiceClient(builder = BodyRootClientBuilder.class) +public final class BodyRootClient { + @Generated + private final BodyRootClientImpl serviceClient; + + /** + * Initializes an instance of BodyRootClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BodyRootClient(BodyRootClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The nested operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     category: String (Optional)
+     *     linkType: String (Optional)
+     *     wasSuccessful: Boolean (Optional)
+     * }
+     * }
+     * 
+ * + * @param bodyRootParameters The bodyRootParameters parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response nestedWithResponse(BinaryData bodyRootParameters, RequestOptions requestOptions) { + return this.serviceClient.nestedWithResponse(bodyRootParameters, requestOptions); + } + + /** + * The nested operation. + * + * @param bodyRootParameters The bodyRootParameters parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void nested(BodyRootModel bodyRootParameters) { + // Generated convenience method for nestedWithResponse + RequestOptions requestOptions = new RequestOptions(); + nestedWithResponse(BinaryData.fromObject(bodyRootParameters), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/BodyRootClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/BodyRootClientBuilder.java new file mode 100644 index 00000000000..e59f9ed5acd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/BodyRootClientBuilder.java @@ -0,0 +1,287 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.bodyroot; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.client.traits.ConfigurationTrait; +import com.azure.core.client.traits.EndpointTrait; +import com.azure.core.client.traits.HttpTrait; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.HttpPipelinePosition; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.AddHeadersFromContextPolicy; +import com.azure.core.http.policy.AddHeadersPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryOptions; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.util.ClientOptions; +import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.builder.ClientBuilderUtil; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.serializer.JacksonAdapter; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import parameters.bodyroot.implementation.BodyRootClientImpl; + +/** + * A builder for creating a new instance of the BodyRootClient type. + */ +@ServiceClientBuilder(serviceClients = { BodyRootClient.class, BodyRootAsyncClient.class }) +public final class BodyRootClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { + @Generated + private static final String SDK_NAME = "name"; + + @Generated + private static final String SDK_VERSION = "version"; + + @Generated + private static final Map PROPERTIES = CoreUtils.getProperties("parameters-bodyroot.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the BodyRootClientBuilder. + */ + @Generated + public BodyRootClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BodyRootClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BodyRootClientBuilder pipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BodyRootClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The client options such as application ID and custom headers to set on a request. + */ + @Generated + private ClientOptions clientOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BodyRootClientBuilder clientOptions(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Generated + private RetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BodyRootClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BodyRootClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Generated + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BodyRootClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BodyRootClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * The retry policy that will attempt to retry failed requests, if applicable. + */ + @Generated + private RetryPolicy retryPolicy; + + /** + * Sets The retry policy that will attempt to retry failed requests, if applicable. + * + * @param retryPolicy the retryPolicy value. + * @return the BodyRootClientBuilder. + */ + @Generated + public BodyRootClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of BodyRootClientImpl with the provided parameters. + * + * @return an instance of BodyRootClientImpl. + */ + @Generated + private BodyRootClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + BodyRootClientImpl client + = new BodyRootClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); + return client; + } + + @Generated + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Generated + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + ClientOptions localClientOptions = this.clientOptions == null ? new ClientOptions() : this.clientOptions; + List policies = new ArrayList<>(); + String clientName = PROPERTIES.getOrDefault(SDK_NAME, "UnknownName"); + String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); + String applicationId = CoreUtils.getApplicationId(localClientOptions, localHttpLogOptions); + policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration)); + policies.add(new RequestIdPolicy()); + policies.add(new AddHeadersFromContextPolicy()); + HttpHeaders headers = CoreUtils.createHttpHeadersFromClientOptions(localClientOptions); + if (headers != null) { + policies.add(new AddHeadersPolicy(headers)); + } + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .forEach(p -> policies.add(p)); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy())); + policies.add(new AddDatePolicy()); + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .forEach(p -> policies.add(p)); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])) + .httpClient(httpClient) + .clientOptions(localClientOptions) + .build(); + return httpPipeline; + } + + /** + * Builds an instance of BodyRootAsyncClient class. + * + * @return an instance of BodyRootAsyncClient. + */ + @Generated + public BodyRootAsyncClient buildAsyncClient() { + return new BodyRootAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of BodyRootClient class. + * + * @return an instance of BodyRootClient. + */ + @Generated + public BodyRootClient buildClient() { + return new BodyRootClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(BodyRootClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/implementation/BodyRootClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/implementation/BodyRootClientImpl.java new file mode 100644 index 00000000000..6ace16374d5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/implementation/BodyRootClientImpl.java @@ -0,0 +1,205 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.bodyroot.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the BodyRootClient type. + */ +public final class BodyRootClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BodyRootClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * The HTTP pipeline to send requests through. + */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** + * The serializer to serialize an object into a string. + */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + public SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** + * Initializes an instance of BodyRootClient client. + * + * @param endpoint Service host. + */ + public BodyRootClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of BodyRootClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public BodyRootClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of BodyRootClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint Service host. + */ + public BodyRootClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.service = RestProxy.create(BodyRootClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for BodyRootClient to be used by the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "BodyRootClient") + public interface BodyRootClientService { + @Post("/parameters/body-root/nested") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> nested(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData bodyRootParameters, RequestOptions requestOptions, + Context context); + + @Post("/parameters/body-root/nested") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response nestedSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData bodyRootParameters, RequestOptions requestOptions, + Context context); + } + + /** + * The nested operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     category: String (Optional)
+     *     linkType: String (Optional)
+     *     wasSuccessful: Boolean (Optional)
+     * }
+     * }
+     * 
+ * + * @param bodyRootParameters The bodyRootParameters parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> nestedWithResponseAsync(BinaryData bodyRootParameters, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.nested(this.getEndpoint(), contentType, bodyRootParameters, requestOptions, context)); + } + + /** + * The nested operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     category: String (Optional)
+     *     linkType: String (Optional)
+     *     wasSuccessful: Boolean (Optional)
+     * }
+     * }
+     * 
+ * + * @param bodyRootParameters The bodyRootParameters parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response nestedWithResponse(BinaryData bodyRootParameters, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.nestedSync(this.getEndpoint(), contentType, bodyRootParameters, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/implementation/package-info.java new file mode 100644 index 00000000000..2141462a093 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/implementation/package-info.java @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * + * Package containing the implementations for BodyRoot. + * Test for @bodyRoot parameter patterns. + * + */ +package parameters.bodyroot.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/models/BodyRootModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/models/BodyRootModel.java new file mode 100644 index 00000000000..12265da15c1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/models/BodyRootModel.java @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.bodyroot.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The BodyRootModel model. + */ +@Fluent +public final class BodyRootModel implements JsonSerializable { + /* + * The category property. + */ + @Generated + private String category; + + /* + * The linkType property. + */ + @Generated + private String linkType; + + /* + * The wasSuccessful property. + */ + @Generated + private Boolean wasSuccessful; + + /** + * Creates an instance of BodyRootModel class. + */ + @Generated + public BodyRootModel() { + } + + /** + * Get the category property: The category property. + * + * @return the category value. + */ + @Generated + public String getCategory() { + return this.category; + } + + /** + * Set the category property: The category property. + * + * @param category the category value to set. + * @return the BodyRootModel object itself. + */ + @Generated + public BodyRootModel setCategory(String category) { + this.category = category; + return this; + } + + /** + * Get the linkType property: The linkType property. + * + * @return the linkType value. + */ + @Generated + public String getLinkType() { + return this.linkType; + } + + /** + * Set the linkType property: The linkType property. + * + * @param linkType the linkType value to set. + * @return the BodyRootModel object itself. + */ + @Generated + public BodyRootModel setLinkType(String linkType) { + this.linkType = linkType; + return this; + } + + /** + * Get the wasSuccessful property: The wasSuccessful property. + * + * @return the wasSuccessful value. + */ + @Generated + public Boolean isWasSuccessful() { + return this.wasSuccessful; + } + + /** + * Set the wasSuccessful property: The wasSuccessful property. + * + * @param wasSuccessful the wasSuccessful value to set. + * @return the BodyRootModel object itself. + */ + @Generated + public BodyRootModel setWasSuccessful(Boolean wasSuccessful) { + this.wasSuccessful = wasSuccessful; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("category", this.category); + jsonWriter.writeStringField("linkType", this.linkType); + jsonWriter.writeBooleanField("wasSuccessful", this.wasSuccessful); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BodyRootModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BodyRootModel if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the BodyRootModel. + */ + @Generated + public static BodyRootModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BodyRootModel deserializedBodyRootModel = new BodyRootModel(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("category".equals(fieldName)) { + deserializedBodyRootModel.category = reader.getString(); + } else if ("linkType".equals(fieldName)) { + deserializedBodyRootModel.linkType = reader.getString(); + } else if ("wasSuccessful".equals(fieldName)) { + deserializedBodyRootModel.wasSuccessful = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } + + return deserializedBodyRootModel; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/models/package-info.java new file mode 100644 index 00000000000..9bfbfdc8a63 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/models/package-info.java @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * + * Package containing the data models for BodyRoot. + * Test for @bodyRoot parameter patterns. + * + */ +package parameters.bodyroot.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/package-info.java new file mode 100644 index 00000000000..40a4d5626da --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/package-info.java @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * + * Package containing the classes for BodyRoot. + * Test for @bodyRoot parameter patterns. + * + */ +package parameters.bodyroot; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/QueryAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/ConstantAsyncClient.java similarity index 95% rename from packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/QueryAsyncClient.java rename to packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/ConstantAsyncClient.java index d3eaac1971e..ed03f457327 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/QueryAsyncClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/ConstantAsyncClient.java @@ -22,17 +22,17 @@ * Initializes a new instance of the asynchronous QueryClient type. */ @ServiceClient(builder = QueryClientBuilder.class, isAsync = true) -public final class QueryAsyncClient { +public final class ConstantAsyncClient { @Generated private final ConstantsImpl serviceClient; /** - * Initializes an instance of QueryAsyncClient class. + * Initializes an instance of ConstantAsyncClient class. * * @param serviceClient the service client implementation. */ @Generated - QueryAsyncClient(ConstantsImpl serviceClient) { + ConstantAsyncClient(ConstantsImpl serviceClient) { this.serviceClient = serviceClient; } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/QueryClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/ConstantClient.java similarity index 95% rename from packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/QueryClient.java rename to packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/ConstantClient.java index b27e52ec51e..fe781ddfa67 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/QueryClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/ConstantClient.java @@ -20,17 +20,17 @@ * Initializes a new instance of the synchronous QueryClient type. */ @ServiceClient(builder = QueryClientBuilder.class) -public final class QueryClient { +public final class ConstantClient { @Generated private final ConstantsImpl serviceClient; /** - * Initializes an instance of QueryClient class. + * Initializes an instance of ConstantClient class. * * @param serviceClient the service client implementation. */ @Generated - QueryClient(ConstantsImpl serviceClient) { + ConstantClient(ConstantsImpl serviceClient) { this.serviceClient = serviceClient; } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/QueryClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/QueryClientBuilder.java index 49e65770444..2f5f89c4acf 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/QueryClientBuilder.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/QueryClientBuilder.java @@ -40,7 +40,12 @@ /** * A builder for creating a new instance of the QueryClient type. */ -@ServiceClientBuilder(serviceClients = { QueryClient.class, QueryAsyncClient.class }) +@ServiceClientBuilder( + serviceClients = { + ConstantClient.class, + SpecialCharClient.class, + ConstantAsyncClient.class, + SpecialCharAsyncClient.class }) public final class QueryClientBuilder implements HttpTrait, ConfigurationTrait, EndpointTrait { @Generated @@ -264,23 +269,43 @@ private HttpPipeline createHttpPipeline() { } /** - * Builds an instance of QueryAsyncClient class. + * Builds an instance of ConstantAsyncClient class. * - * @return an instance of QueryAsyncClient. + * @return an instance of ConstantAsyncClient. */ @Generated - public QueryAsyncClient buildAsyncClient() { - return new QueryAsyncClient(buildInnerClient().getConstants()); + public ConstantAsyncClient buildConstantAsyncClient() { + return new ConstantAsyncClient(buildInnerClient().getConstants()); } /** - * Builds an instance of QueryClient class. + * Builds an instance of SpecialCharAsyncClient class. * - * @return an instance of QueryClient. + * @return an instance of SpecialCharAsyncClient. */ @Generated - public QueryClient buildClient() { - return new QueryClient(buildInnerClient().getConstants()); + public SpecialCharAsyncClient buildSpecialCharAsyncClient() { + return new SpecialCharAsyncClient(buildInnerClient().getSpecialChars()); + } + + /** + * Builds an instance of ConstantClient class. + * + * @return an instance of ConstantClient. + */ + @Generated + public ConstantClient buildConstantClient() { + return new ConstantClient(buildInnerClient().getConstants()); + } + + /** + * Builds an instance of SpecialCharClient class. + * + * @return an instance of SpecialCharClient. + */ + @Generated + public SpecialCharClient buildSpecialCharClient() { + return new SpecialCharClient(buildInnerClient().getSpecialChars()); } private static final ClientLogger LOGGER = new ClientLogger(QueryClientBuilder.class); diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/SpecialCharAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/SpecialCharAsyncClient.java new file mode 100644 index 00000000000..b4756be4677 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/SpecialCharAsyncClient.java @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.query; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.FluxUtil; +import parameters.query.implementation.SpecialCharsImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous QueryClient type. + */ +@ServiceClient(builder = QueryClientBuilder.class, isAsync = true) +public final class SpecialCharAsyncClient { + @Generated + private final SpecialCharsImpl serviceClient; + + /** + * Initializes an instance of SpecialCharAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpecialCharAsyncClient(SpecialCharsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The dollarSign operation. + * + * @param filter The filter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> dollarSignWithResponse(String filter, RequestOptions requestOptions) { + return this.serviceClient.dollarSignWithResponseAsync(filter, requestOptions); + } + + /** + * The dollarSign operation. + * + * @param filter The filter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono dollarSign(String filter) { + // Generated convenience method for dollarSignWithResponse + RequestOptions requestOptions = new RequestOptions(); + return dollarSignWithResponse(filter, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/SpecialCharClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/SpecialCharClient.java new file mode 100644 index 00000000000..557211a5c0e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/SpecialCharClient.java @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.query; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import parameters.query.implementation.SpecialCharsImpl; + +/** + * Initializes a new instance of the synchronous QueryClient type. + */ +@ServiceClient(builder = QueryClientBuilder.class) +public final class SpecialCharClient { + @Generated + private final SpecialCharsImpl serviceClient; + + /** + * Initializes an instance of SpecialCharClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpecialCharClient(SpecialCharsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The dollarSign operation. + * + * @param filter The filter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response dollarSignWithResponse(String filter, RequestOptions requestOptions) { + return this.serviceClient.dollarSignWithResponse(filter, requestOptions); + } + + /** + * The dollarSign operation. + * + * @param filter The filter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void dollarSign(String filter) { + // Generated convenience method for dollarSignWithResponse + RequestOptions requestOptions = new RequestOptions(); + dollarSignWithResponse(filter, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/implementation/QueryClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/implementation/QueryClientImpl.java index 1a7823bfd4d..87888470a27 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/implementation/QueryClientImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/implementation/QueryClientImpl.java @@ -71,6 +71,20 @@ public ConstantsImpl getConstants() { return this.constants; } + /** + * The SpecialCharsImpl object to access its operations. + */ + private final SpecialCharsImpl specialChars; + + /** + * Gets the SpecialCharsImpl object to access its operations. + * + * @return the SpecialCharsImpl object. + */ + public SpecialCharsImpl getSpecialChars() { + return this.specialChars; + } + /** * Initializes an instance of QueryClient client. * @@ -103,5 +117,6 @@ public QueryClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAd this.serializerAdapter = serializerAdapter; this.endpoint = endpoint; this.constants = new ConstantsImpl(this); + this.specialChars = new SpecialCharsImpl(this); } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/implementation/SpecialCharsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/implementation/SpecialCharsImpl.java new file mode 100644 index 00000000000..c3f1289ed2e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/implementation/SpecialCharsImpl.java @@ -0,0 +1,110 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.query.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in SpecialChars. + */ +public final class SpecialCharsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SpecialCharsService service; + + /** + * The service client containing this operation class. + */ + private final QueryClientImpl client; + + /** + * Initializes an instance of SpecialCharsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SpecialCharsImpl(QueryClientImpl client) { + this.service + = RestProxy.create(SpecialCharsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for QueryClientSpecialChars to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "QueryClientSpecialChars") + public interface SpecialCharsService { + @Get("/parameters/query/special-char/dollarSign") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> dollarSign(@HostParam("endpoint") String endpoint, @QueryParam("$filter") String filter, + RequestOptions requestOptions, Context context); + + @Get("/parameters/query/special-char/dollarSign") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response dollarSignSync(@HostParam("endpoint") String endpoint, @QueryParam("$filter") String filter, + RequestOptions requestOptions, Context context); + } + + /** + * The dollarSign operation. + * + * @param filter The filter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> dollarSignWithResponseAsync(String filter, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.dollarSign(this.client.getEndpoint(), filter, requestOptions, context)); + } + + /** + * The dollarSign operation. + * + * @param filter The filter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response dollarSignWithResponse(String filter, RequestOptions requestOptions) { + return service.dollarSignSync(this.client.getEndpoint(), filter, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorAsyncClient.java index 770d0e65de8..d5b74270f0f 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorAsyncClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorAsyncClient.java @@ -20,6 +20,7 @@ import type.model.inheritance.singlediscriminator.implementation.SingleDiscriminatorClientImpl; import type.model.inheritance.singlediscriminator.models.Bird; import type.model.inheritance.singlediscriminator.models.Dinosaur; +import type.model.inheritance.singlediscriminator.models.Fish; /** * Initializes a new instance of the asynchronous SingleDiscriminatorClient type. @@ -228,6 +229,60 @@ public Mono> getLegacyModelWithResponse(RequestOptions requ return this.serviceClient.getLegacyModelWithResponseAsync(requestOptions); } + /** + * The getNoSubtypesModel operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     size: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a discriminated model with no defined subtypes along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNoSubtypesModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNoSubtypesModelWithResponseAsync(requestOptions); + } + + /** + * The putNoSubtypesModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     size: int (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> putNoSubtypesModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putNoSubtypesModelWithResponseAsync(input, requestOptions); + } + /** * The getModel operation. * @@ -366,4 +421,43 @@ public Mono getLegacyModel() { return getLegacyModelWithResponse(requestOptions).flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(Dinosaur.class)); } + + /** + * The getNoSubtypesModel operation. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a discriminated model with no defined subtypes on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getNoSubtypesModel() { + // Generated convenience method for getNoSubtypesModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNoSubtypesModelWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Fish.class)); + } + + /** + * The putNoSubtypesModel operation. + * + * @param input The input parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono putNoSubtypesModel(Fish input) { + // Generated convenience method for putNoSubtypesModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putNoSubtypesModelWithResponse(BinaryData.fromObject(input), requestOptions).flatMap(FluxUtil::toMono); + } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java index 004c639ff53..ec98358efa0 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java @@ -18,6 +18,7 @@ import type.model.inheritance.singlediscriminator.implementation.SingleDiscriminatorClientImpl; import type.model.inheritance.singlediscriminator.models.Bird; import type.model.inheritance.singlediscriminator.models.Dinosaur; +import type.model.inheritance.singlediscriminator.models.Fish; /** * Initializes a new instance of the synchronous SingleDiscriminatorClient type. @@ -225,6 +226,59 @@ public Response getLegacyModelWithResponse(RequestOptions requestOpt return this.serviceClient.getLegacyModelWithResponse(requestOptions); } + /** + * The getNoSubtypesModel operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     size: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a discriminated model with no defined subtypes along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNoSubtypesModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNoSubtypesModelWithResponse(requestOptions); + } + + /** + * The putNoSubtypesModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     size: int (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putNoSubtypesModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putNoSubtypesModelWithResponse(input, requestOptions); + } + /** * The getModel operation. * @@ -352,4 +406,41 @@ public Dinosaur getLegacyModel() { RequestOptions requestOptions = new RequestOptions(); return getLegacyModelWithResponse(requestOptions).getValue().toObject(Dinosaur.class); } + + /** + * The getNoSubtypesModel operation. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a discriminated model with no defined subtypes. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Fish getNoSubtypesModel() { + // Generated convenience method for getNoSubtypesModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNoSubtypesModelWithResponse(requestOptions).getValue().toObject(Fish.class); + } + + /** + * The putNoSubtypesModel operation. + * + * @param input The input parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void putNoSubtypesModel(Fish input) { + // Generated convenience method for putNoSubtypesModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + putNoSubtypesModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java index 59e696cf8e9..eb42cfeb8c5 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java @@ -256,6 +256,44 @@ Mono> getLegacyModel(@HostParam("endpoint") String endpoint @UnexpectedResponseExceptionType(HttpResponseException.class) Response getLegacyModelSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/single-discriminator/no-subtypes/model") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getNoSubtypesModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/single-discriminator/no-subtypes/model") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getNoSubtypesModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/type/model/inheritance/single-discriminator/no-subtypes/model") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putNoSubtypesModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Put("/type/model/inheritance/single-discriminator/no-subtypes/model") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putNoSubtypesModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); } /** @@ -640,4 +678,113 @@ public Response getLegacyModelWithResponse(RequestOptions requestOpt final String accept = "application/json"; return service.getLegacyModelSync(this.getEndpoint(), accept, requestOptions, Context.NONE); } + + /** + * The getNoSubtypesModel operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     size: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a discriminated model with no defined subtypes along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNoSubtypesModelWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getNoSubtypesModel(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getNoSubtypesModel operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     size: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a discriminated model with no defined subtypes along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNoSubtypesModelWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNoSubtypesModelSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The putNoSubtypesModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     size: int (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> putNoSubtypesModelWithResponseAsync(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putNoSubtypesModel(this.getEndpoint(), contentType, input, requestOptions, context)); + } + + /** + * The putNoSubtypesModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     size: int (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putNoSubtypesModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putNoSubtypesModelSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); + } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/models/Fish.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/models/Fish.java new file mode 100644 index 00000000000..0dd3d145dcf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/models/Fish.java @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.singlediscriminator.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * A discriminated model with no defined subtypes. The discriminator is declared but no models extend it. + */ +@Immutable +public final class Fish implements JsonSerializable { + /* + * The kind property. + */ + @Generated + private String kind = "Fish"; + + /* + * The size property. + */ + @Generated + private final int size; + + /** + * Creates an instance of Fish class. + * + * @param size the size value to set. + */ + @Generated + public Fish(int size) { + this.size = size; + } + + /** + * Get the kind property: The kind property. + * + * @return the kind value. + */ + @Generated + public String getKind() { + return this.kind; + } + + /** + * Get the size property: The size property. + * + * @return the size value. + */ + @Generated + public int getSize() { + return this.size; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("size", this.size); + jsonWriter.writeStringField("kind", this.kind); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Fish from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Fish if the JsonReader was pointing to an instance of it, or null if it was pointing to + * JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the Fish. + */ + @Generated + public static Fish fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int size = 0; + String kind = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("size".equals(fieldName)) { + size = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = reader.getString(); + } else { + reader.skipChildren(); + } + } + Fish deserializedFish = new Fish(size); + deserializedFish.kind = kind; + + return deserializedFish; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-commonproperties-generated_metadata.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-commonproperties-generated_metadata.json index 0fdaa16cc0e..c94b2877527 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-commonproperties-generated_metadata.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-commonproperties-generated_metadata.json @@ -1 +1 @@ -{"flavor":"Azure","apiVersions":{"Azure.ResourceManager.CommonProperties":"2023-12-01-preview"},"crossLanguagePackageId":"Azure.ResourceManager.CommonProperties","crossLanguageVersion":"ad207ac2ccc3","crossLanguageDefinitions":{"azure.resourcemanager.commonproperties.fluent.CommonPropertiesClient":"Azure.ResourceManager.CommonProperties","azure.resourcemanager.commonproperties.fluent.ErrorsClient":"Azure.ResourceManager.CommonProperties.Error","azure.resourcemanager.commonproperties.fluent.ErrorsClient.createForUserDefinedError":"Azure.ResourceManager.CommonProperties.Error.createForUserDefinedError","azure.resourcemanager.commonproperties.fluent.ErrorsClient.createForUserDefinedErrorWithResponse":"Azure.ResourceManager.CommonProperties.Error.createForUserDefinedError","azure.resourcemanager.commonproperties.fluent.ErrorsClient.getByResourceGroup":"Azure.ResourceManager.CommonProperties.Error.getForPredefinedError","azure.resourcemanager.commonproperties.fluent.ErrorsClient.getByResourceGroupWithResponse":"Azure.ResourceManager.CommonProperties.Error.getForPredefinedError","azure.resourcemanager.commonproperties.fluent.ManagedIdentitiesClient":"Azure.ResourceManager.CommonProperties.ManagedIdentity","azure.resourcemanager.commonproperties.fluent.ManagedIdentitiesClient.createWithSystemAssigned":"Azure.ResourceManager.CommonProperties.ManagedIdentity.createWithSystemAssigned","azure.resourcemanager.commonproperties.fluent.ManagedIdentitiesClient.createWithSystemAssignedWithResponse":"Azure.ResourceManager.CommonProperties.ManagedIdentity.createWithSystemAssigned","azure.resourcemanager.commonproperties.fluent.ManagedIdentitiesClient.getByResourceGroup":"Azure.ResourceManager.CommonProperties.ManagedIdentity.get","azure.resourcemanager.commonproperties.fluent.ManagedIdentitiesClient.getByResourceGroupWithResponse":"Azure.ResourceManager.CommonProperties.ManagedIdentity.get","azure.resourcemanager.commonproperties.fluent.ManagedIdentitiesClient.updateWithUserAssignedAndSystemAssigned":"Azure.ResourceManager.CommonProperties.ManagedIdentity.updateWithUserAssignedAndSystemAssigned","azure.resourcemanager.commonproperties.fluent.ManagedIdentitiesClient.updateWithUserAssignedAndSystemAssignedWithResponse":"Azure.ResourceManager.CommonProperties.ManagedIdentity.updateWithUserAssignedAndSystemAssigned","azure.resourcemanager.commonproperties.fluent.models.ConfidentialResourceInner":"Azure.ResourceManager.CommonProperties.ConfidentialResource","azure.resourcemanager.commonproperties.fluent.models.ManagedIdentityTrackedResourceInner":"Azure.ResourceManager.CommonProperties.ManagedIdentityTrackedResource","azure.resourcemanager.commonproperties.implementation.CommonPropertiesClientBuilder":"Azure.ResourceManager.CommonProperties","azure.resourcemanager.commonproperties.models.ApiError":"Azure.ResourceManager.CommonProperties.CloudError","azure.resourcemanager.commonproperties.models.ConfidentialResourceProperties":"Azure.ResourceManager.CommonProperties.ConfidentialResourceProperties","azure.resourcemanager.commonproperties.models.InnerError":"Azure.ResourceManager.CommonProperties.InnerError","azure.resourcemanager.commonproperties.models.ManagedIdentityTrackedResourceProperties":"Azure.ResourceManager.CommonProperties.ManagedIdentityTrackedResourceProperties","azure.resourcemanager.commonproperties.models.ManagedServiceIdentity":"Azure.ResourceManager.CommonTypes.ManagedServiceIdentity","azure.resourcemanager.commonproperties.models.ManagedServiceIdentityType":"Azure.ResourceManager.CommonTypes.ManagedServiceIdentityType","azure.resourcemanager.commonproperties.models.UserAssignedIdentity":"Azure.ResourceManager.CommonTypes.UserAssignedIdentity"},"generatedFiles":["src/main/java/azure/resourcemanager/commonproperties/CommonPropertiesManager.java","src/main/java/azure/resourcemanager/commonproperties/fluent/CommonPropertiesClient.java","src/main/java/azure/resourcemanager/commonproperties/fluent/ErrorsClient.java","src/main/java/azure/resourcemanager/commonproperties/fluent/ManagedIdentitiesClient.java","src/main/java/azure/resourcemanager/commonproperties/fluent/models/ConfidentialResourceInner.java","src/main/java/azure/resourcemanager/commonproperties/fluent/models/ManagedIdentityTrackedResourceInner.java","src/main/java/azure/resourcemanager/commonproperties/fluent/models/package-info.java","src/main/java/azure/resourcemanager/commonproperties/fluent/package-info.java","src/main/java/azure/resourcemanager/commonproperties/implementation/CommonPropertiesClientBuilder.java","src/main/java/azure/resourcemanager/commonproperties/implementation/CommonPropertiesClientImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ConfidentialResourceImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ErrorsClientImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ErrorsImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ManagedIdentitiesClientImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ManagedIdentitiesImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ManagedIdentityTrackedResourceImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ResourceManagerUtils.java","src/main/java/azure/resourcemanager/commonproperties/implementation/package-info.java","src/main/java/azure/resourcemanager/commonproperties/models/ApiError.java","src/main/java/azure/resourcemanager/commonproperties/models/ApiErrorException.java","src/main/java/azure/resourcemanager/commonproperties/models/ConfidentialResource.java","src/main/java/azure/resourcemanager/commonproperties/models/ConfidentialResourceProperties.java","src/main/java/azure/resourcemanager/commonproperties/models/Errors.java","src/main/java/azure/resourcemanager/commonproperties/models/InnerError.java","src/main/java/azure/resourcemanager/commonproperties/models/ManagedIdentities.java","src/main/java/azure/resourcemanager/commonproperties/models/ManagedIdentityTrackedResource.java","src/main/java/azure/resourcemanager/commonproperties/models/ManagedIdentityTrackedResourceProperties.java","src/main/java/azure/resourcemanager/commonproperties/models/ManagedServiceIdentity.java","src/main/java/azure/resourcemanager/commonproperties/models/ManagedServiceIdentityType.java","src/main/java/azure/resourcemanager/commonproperties/models/UserAssignedIdentity.java","src/main/java/azure/resourcemanager/commonproperties/models/package-info.java","src/main/java/azure/resourcemanager/commonproperties/package-info.java","src/main/java/module-info.java"]} \ No newline at end of file +{"flavor":"Azure","apiVersions":{"Azure.ResourceManager.CommonProperties":"2023-12-01-preview"},"crossLanguagePackageId":"Azure.ResourceManager.CommonProperties","crossLanguageVersion":"f9b539c8f6ce","crossLanguageDefinitions":{"azure.resourcemanager.commonproperties.fluent.ArmResourceIdentifiersClient":"Azure.ResourceManager.CommonProperties.ArmResourceIdentifiers","azure.resourcemanager.commonproperties.fluent.ArmResourceIdentifiersClient.createOrReplace":"Azure.ResourceManager.CommonProperties.ArmResourceIdentifiers.createOrReplace","azure.resourcemanager.commonproperties.fluent.ArmResourceIdentifiersClient.createOrReplaceWithResponse":"Azure.ResourceManager.CommonProperties.ArmResourceIdentifiers.createOrReplace","azure.resourcemanager.commonproperties.fluent.ArmResourceIdentifiersClient.getByResourceGroup":"Azure.ResourceManager.CommonProperties.ArmResourceIdentifiers.get","azure.resourcemanager.commonproperties.fluent.ArmResourceIdentifiersClient.getByResourceGroupWithResponse":"Azure.ResourceManager.CommonProperties.ArmResourceIdentifiers.get","azure.resourcemanager.commonproperties.fluent.CommonPropertiesClient":"Azure.ResourceManager.CommonProperties","azure.resourcemanager.commonproperties.fluent.ErrorsClient":"Azure.ResourceManager.CommonProperties.Error","azure.resourcemanager.commonproperties.fluent.ErrorsClient.createForUserDefinedError":"Azure.ResourceManager.CommonProperties.Error.createForUserDefinedError","azure.resourcemanager.commonproperties.fluent.ErrorsClient.createForUserDefinedErrorWithResponse":"Azure.ResourceManager.CommonProperties.Error.createForUserDefinedError","azure.resourcemanager.commonproperties.fluent.ErrorsClient.getByResourceGroup":"Azure.ResourceManager.CommonProperties.Error.getForPredefinedError","azure.resourcemanager.commonproperties.fluent.ErrorsClient.getByResourceGroupWithResponse":"Azure.ResourceManager.CommonProperties.Error.getForPredefinedError","azure.resourcemanager.commonproperties.fluent.ManagedIdentitiesClient":"Azure.ResourceManager.CommonProperties.ManagedIdentity","azure.resourcemanager.commonproperties.fluent.ManagedIdentitiesClient.createWithSystemAssigned":"Azure.ResourceManager.CommonProperties.ManagedIdentity.createWithSystemAssigned","azure.resourcemanager.commonproperties.fluent.ManagedIdentitiesClient.createWithSystemAssignedWithResponse":"Azure.ResourceManager.CommonProperties.ManagedIdentity.createWithSystemAssigned","azure.resourcemanager.commonproperties.fluent.ManagedIdentitiesClient.getByResourceGroup":"Azure.ResourceManager.CommonProperties.ManagedIdentity.get","azure.resourcemanager.commonproperties.fluent.ManagedIdentitiesClient.getByResourceGroupWithResponse":"Azure.ResourceManager.CommonProperties.ManagedIdentity.get","azure.resourcemanager.commonproperties.fluent.ManagedIdentitiesClient.updateWithUserAssignedAndSystemAssigned":"Azure.ResourceManager.CommonProperties.ManagedIdentity.updateWithUserAssignedAndSystemAssigned","azure.resourcemanager.commonproperties.fluent.ManagedIdentitiesClient.updateWithUserAssignedAndSystemAssignedWithResponse":"Azure.ResourceManager.CommonProperties.ManagedIdentity.updateWithUserAssignedAndSystemAssigned","azure.resourcemanager.commonproperties.fluent.models.ArmResourceIdentifierResourceInner":"Azure.ResourceManager.CommonProperties.ArmResourceIdentifierResource","azure.resourcemanager.commonproperties.fluent.models.ConfidentialResourceInner":"Azure.ResourceManager.CommonProperties.ConfidentialResource","azure.resourcemanager.commonproperties.fluent.models.ManagedIdentityTrackedResourceInner":"Azure.ResourceManager.CommonProperties.ManagedIdentityTrackedResource","azure.resourcemanager.commonproperties.implementation.CommonPropertiesClientBuilder":"Azure.ResourceManager.CommonProperties","azure.resourcemanager.commonproperties.models.ApiError":"Azure.ResourceManager.CommonProperties.CloudError","azure.resourcemanager.commonproperties.models.ArmResourceIdentifierResourceProperties":"Azure.ResourceManager.CommonProperties.ArmResourceIdentifierResourceProperties","azure.resourcemanager.commonproperties.models.ConfidentialResourceProperties":"Azure.ResourceManager.CommonProperties.ConfidentialResourceProperties","azure.resourcemanager.commonproperties.models.InnerError":"Azure.ResourceManager.CommonProperties.InnerError","azure.resourcemanager.commonproperties.models.ManagedIdentityTrackedResourceProperties":"Azure.ResourceManager.CommonProperties.ManagedIdentityTrackedResourceProperties","azure.resourcemanager.commonproperties.models.ManagedServiceIdentity":"Azure.ResourceManager.CommonTypes.ManagedServiceIdentity","azure.resourcemanager.commonproperties.models.ManagedServiceIdentityType":"Azure.ResourceManager.CommonTypes.ManagedServiceIdentityType","azure.resourcemanager.commonproperties.models.ResourceProvisioningState":"Azure.ResourceManager.ResourceProvisioningState","azure.resourcemanager.commonproperties.models.UserAssignedIdentity":"Azure.ResourceManager.CommonTypes.UserAssignedIdentity"},"generatedFiles":["src/main/java/azure/resourcemanager/commonproperties/CommonPropertiesManager.java","src/main/java/azure/resourcemanager/commonproperties/fluent/ArmResourceIdentifiersClient.java","src/main/java/azure/resourcemanager/commonproperties/fluent/CommonPropertiesClient.java","src/main/java/azure/resourcemanager/commonproperties/fluent/ErrorsClient.java","src/main/java/azure/resourcemanager/commonproperties/fluent/ManagedIdentitiesClient.java","src/main/java/azure/resourcemanager/commonproperties/fluent/models/ArmResourceIdentifierResourceInner.java","src/main/java/azure/resourcemanager/commonproperties/fluent/models/ConfidentialResourceInner.java","src/main/java/azure/resourcemanager/commonproperties/fluent/models/ManagedIdentityTrackedResourceInner.java","src/main/java/azure/resourcemanager/commonproperties/fluent/models/package-info.java","src/main/java/azure/resourcemanager/commonproperties/fluent/package-info.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ArmResourceIdentifierResourceImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ArmResourceIdentifiersClientImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ArmResourceIdentifiersImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/CommonPropertiesClientBuilder.java","src/main/java/azure/resourcemanager/commonproperties/implementation/CommonPropertiesClientImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ConfidentialResourceImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ErrorsClientImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ErrorsImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ManagedIdentitiesClientImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ManagedIdentitiesImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ManagedIdentityTrackedResourceImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ResourceManagerUtils.java","src/main/java/azure/resourcemanager/commonproperties/implementation/package-info.java","src/main/java/azure/resourcemanager/commonproperties/models/ApiError.java","src/main/java/azure/resourcemanager/commonproperties/models/ApiErrorException.java","src/main/java/azure/resourcemanager/commonproperties/models/ArmResourceIdentifierResource.java","src/main/java/azure/resourcemanager/commonproperties/models/ArmResourceIdentifierResourceProperties.java","src/main/java/azure/resourcemanager/commonproperties/models/ArmResourceIdentifiers.java","src/main/java/azure/resourcemanager/commonproperties/models/ConfidentialResource.java","src/main/java/azure/resourcemanager/commonproperties/models/ConfidentialResourceProperties.java","src/main/java/azure/resourcemanager/commonproperties/models/Errors.java","src/main/java/azure/resourcemanager/commonproperties/models/InnerError.java","src/main/java/azure/resourcemanager/commonproperties/models/ManagedIdentities.java","src/main/java/azure/resourcemanager/commonproperties/models/ManagedIdentityTrackedResource.java","src/main/java/azure/resourcemanager/commonproperties/models/ManagedIdentityTrackedResourceProperties.java","src/main/java/azure/resourcemanager/commonproperties/models/ManagedServiceIdentity.java","src/main/java/azure/resourcemanager/commonproperties/models/ManagedServiceIdentityType.java","src/main/java/azure/resourcemanager/commonproperties/models/ResourceProvisioningState.java","src/main/java/azure/resourcemanager/commonproperties/models/UserAssignedIdentity.java","src/main/java/azure/resourcemanager/commonproperties/models/package-info.java","src/main/java/azure/resourcemanager/commonproperties/package-info.java","src/main/java/module-info.java"]} \ No newline at end of file diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-managementgroup-generated_metadata.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-managementgroup-generated_metadata.json new file mode 100644 index 00000000000..30e65e9c296 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-managementgroup-generated_metadata.json @@ -0,0 +1 @@ +{"flavor":"Azure","apiVersions":{"Azure.ResourceManager.ManagementGroup":"2023-12-01-preview"},"crossLanguagePackageId":"Azure.ResourceManager.ManagementGroup","crossLanguageVersion":"f15d0d496982","crossLanguageDefinitions":{"azure.resourcemanager.managementgroup.fluent.ManagementGroupChildResourcesClient":"Azure.ResourceManager.ManagementGroup.ManagementGroupChildResources","azure.resourcemanager.managementgroup.fluent.ManagementGroupChildResourcesClient.beginCreateOrUpdate":"Azure.ResourceManager.ManagementGroup.ManagementGroupChildResources.createOrUpdate","azure.resourcemanager.managementgroup.fluent.ManagementGroupChildResourcesClient.createOrUpdate":"Azure.ResourceManager.ManagementGroup.ManagementGroupChildResources.createOrUpdate","azure.resourcemanager.managementgroup.fluent.ManagementGroupChildResourcesClient.delete":"Azure.ResourceManager.ManagementGroup.ManagementGroupChildResources.delete","azure.resourcemanager.managementgroup.fluent.ManagementGroupChildResourcesClient.deleteWithResponse":"Azure.ResourceManager.ManagementGroup.ManagementGroupChildResources.delete","azure.resourcemanager.managementgroup.fluent.ManagementGroupChildResourcesClient.get":"Azure.ResourceManager.ManagementGroup.ManagementGroupChildResources.get","azure.resourcemanager.managementgroup.fluent.ManagementGroupChildResourcesClient.getWithResponse":"Azure.ResourceManager.ManagementGroup.ManagementGroupChildResources.get","azure.resourcemanager.managementgroup.fluent.ManagementGroupChildResourcesClient.listByManagementGroup":"Azure.ResourceManager.ManagementGroup.ManagementGroupChildResources.listByManagementGroup","azure.resourcemanager.managementgroup.fluent.ManagementGroupChildResourcesClient.update":"Azure.ResourceManager.ManagementGroup.ManagementGroupChildResources.update","azure.resourcemanager.managementgroup.fluent.ManagementGroupChildResourcesClient.updateWithResponse":"Azure.ResourceManager.ManagementGroup.ManagementGroupChildResources.update","azure.resourcemanager.managementgroup.fluent.ManagementGroupClient":"Azure.ResourceManager.ManagementGroup","azure.resourcemanager.managementgroup.fluent.models.ManagementGroupChildResourceInner":"Azure.ResourceManager.ManagementGroup.ManagementGroupChildResource","azure.resourcemanager.managementgroup.implementation.ManagementGroupClientBuilder":"Azure.ResourceManager.ManagementGroup","azure.resourcemanager.managementgroup.implementation.models.ManagementGroupChildResourceListResult":"Azure.ResourceManager.ResourceListResult","azure.resourcemanager.managementgroup.models.ManagementGroupChildResourceProperties":"Azure.ResourceManager.ManagementGroup.ManagementGroupChildResourceProperties","azure.resourcemanager.managementgroup.models.ProvisioningState":"Azure.ResourceManager.ManagementGroup.ProvisioningState"},"generatedFiles":["src/main/java/azure/resourcemanager/managementgroup/ManagementGroupManager.java","src/main/java/azure/resourcemanager/managementgroup/fluent/ManagementGroupChildResourcesClient.java","src/main/java/azure/resourcemanager/managementgroup/fluent/ManagementGroupClient.java","src/main/java/azure/resourcemanager/managementgroup/fluent/models/ManagementGroupChildResourceInner.java","src/main/java/azure/resourcemanager/managementgroup/fluent/models/package-info.java","src/main/java/azure/resourcemanager/managementgroup/fluent/package-info.java","src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupChildResourceImpl.java","src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupChildResourcesClientImpl.java","src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupChildResourcesImpl.java","src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupClientBuilder.java","src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupClientImpl.java","src/main/java/azure/resourcemanager/managementgroup/implementation/ResourceManagerUtils.java","src/main/java/azure/resourcemanager/managementgroup/implementation/models/ManagementGroupChildResourceListResult.java","src/main/java/azure/resourcemanager/managementgroup/implementation/package-info.java","src/main/java/azure/resourcemanager/managementgroup/models/ManagementGroupChildResource.java","src/main/java/azure/resourcemanager/managementgroup/models/ManagementGroupChildResourceProperties.java","src/main/java/azure/resourcemanager/managementgroup/models/ManagementGroupChildResources.java","src/main/java/azure/resourcemanager/managementgroup/models/ProvisioningState.java","src/main/java/azure/resourcemanager/managementgroup/models/package-info.java","src/main/java/azure/resourcemanager/managementgroup/package-info.java","src/main/java/module-info.java"]} \ No newline at end of file diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-commonproperties-generated/proxy-config.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-commonproperties-generated/proxy-config.json index cdd07e3847c..9d7165df93d 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-commonproperties-generated/proxy-config.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-commonproperties-generated/proxy-config.json @@ -1 +1 @@ -[["azure.resourcemanager.commonproperties.implementation.ErrorsClientImpl$ErrorsService"],["azure.resourcemanager.commonproperties.implementation.ManagedIdentitiesClientImpl$ManagedIdentitiesService"]] \ No newline at end of file +[["azure.resourcemanager.commonproperties.implementation.ArmResourceIdentifiersClientImpl$ArmResourceIdentifiersService"],["azure.resourcemanager.commonproperties.implementation.ErrorsClientImpl$ErrorsService"],["azure.resourcemanager.commonproperties.implementation.ManagedIdentitiesClientImpl$ManagedIdentitiesService"]] \ No newline at end of file diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-managementgroup-generated/proxy-config.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-managementgroup-generated/proxy-config.json new file mode 100644 index 00000000000..ee2057bbcba --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-managementgroup-generated/proxy-config.json @@ -0,0 +1 @@ +[["azure.resourcemanager.managementgroup.implementation.ManagementGroupChildResourcesClientImpl$ManagementGroupChildResourcesService"]] \ No newline at end of file diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-managementgroup-generated/reflect-config.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-managementgroup-generated/reflect-config.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-managementgroup-generated/reflect-config.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/parameters-bodyroot_metadata.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/parameters-bodyroot_metadata.json new file mode 100644 index 00000000000..2048222e2a0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/parameters-bodyroot_metadata.json @@ -0,0 +1 @@ +{"flavor":"Azure","apiVersions":{},"crossLanguagePackageId":"Parameters.BodyRoot","crossLanguageVersion":"1b93bc1e60f7","crossLanguageDefinitions":{"parameters.bodyroot.BodyRootAsyncClient":"Parameters.BodyRoot","parameters.bodyroot.BodyRootAsyncClient.nested":"Parameters.BodyRoot.nested","parameters.bodyroot.BodyRootAsyncClient.nestedWithResponse":"Parameters.BodyRoot.nested","parameters.bodyroot.BodyRootClient":"Parameters.BodyRoot","parameters.bodyroot.BodyRootClient.nested":"Parameters.BodyRoot.nested","parameters.bodyroot.BodyRootClient.nestedWithResponse":"Parameters.BodyRoot.nested","parameters.bodyroot.BodyRootClientBuilder":"Parameters.BodyRoot","parameters.bodyroot.models.BodyRootModel":"Parameters.BodyRoot.BodyRootModel"},"generatedFiles":["src/main/java/module-info.java","src/main/java/parameters/bodyroot/BodyRootAsyncClient.java","src/main/java/parameters/bodyroot/BodyRootClient.java","src/main/java/parameters/bodyroot/BodyRootClientBuilder.java","src/main/java/parameters/bodyroot/implementation/BodyRootClientImpl.java","src/main/java/parameters/bodyroot/implementation/package-info.java","src/main/java/parameters/bodyroot/models/BodyRootModel.java","src/main/java/parameters/bodyroot/models/package-info.java","src/main/java/parameters/bodyroot/package-info.java"]} \ No newline at end of file diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/parameters-query_metadata.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/parameters-query_metadata.json index ecff4386b60..d2540b329d8 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/parameters-query_metadata.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/parameters-query_metadata.json @@ -1 +1 @@ -{"flavor":"Azure","apiVersions":{},"crossLanguagePackageId":"Parameters.Query","crossLanguageVersion":"e2bfb58d3cc1","crossLanguageDefinitions":{"parameters.query.QueryAsyncClient":"Parameters.Query.Constant","parameters.query.QueryAsyncClient.post":"Parameters.Query.Constant.post","parameters.query.QueryAsyncClient.postWithResponse":"Parameters.Query.Constant.post","parameters.query.QueryClient":"Parameters.Query.Constant","parameters.query.QueryClient.post":"Parameters.Query.Constant.post","parameters.query.QueryClient.postWithResponse":"Parameters.Query.Constant.post","parameters.query.QueryClientBuilder":"Parameters.Query"},"generatedFiles":["src/main/java/module-info.java","src/main/java/parameters/query/QueryAsyncClient.java","src/main/java/parameters/query/QueryClient.java","src/main/java/parameters/query/QueryClientBuilder.java","src/main/java/parameters/query/implementation/ConstantsImpl.java","src/main/java/parameters/query/implementation/QueryClientImpl.java","src/main/java/parameters/query/implementation/package-info.java","src/main/java/parameters/query/package-info.java"]} \ No newline at end of file +{"flavor":"Azure","apiVersions":{},"crossLanguagePackageId":"Parameters.Query","crossLanguageVersion":"d221aa20c419","crossLanguageDefinitions":{"parameters.query.ConstantAsyncClient":"Parameters.Query.Constant","parameters.query.ConstantAsyncClient.post":"Parameters.Query.Constant.post","parameters.query.ConstantAsyncClient.postWithResponse":"Parameters.Query.Constant.post","parameters.query.ConstantClient":"Parameters.Query.Constant","parameters.query.ConstantClient.post":"Parameters.Query.Constant.post","parameters.query.ConstantClient.postWithResponse":"Parameters.Query.Constant.post","parameters.query.QueryClientBuilder":"Parameters.Query","parameters.query.SpecialCharAsyncClient":"Parameters.Query.SpecialChar","parameters.query.SpecialCharAsyncClient.dollarSign":"Parameters.Query.SpecialChar.dollarSign","parameters.query.SpecialCharAsyncClient.dollarSignWithResponse":"Parameters.Query.SpecialChar.dollarSign","parameters.query.SpecialCharClient":"Parameters.Query.SpecialChar","parameters.query.SpecialCharClient.dollarSign":"Parameters.Query.SpecialChar.dollarSign","parameters.query.SpecialCharClient.dollarSignWithResponse":"Parameters.Query.SpecialChar.dollarSign"},"generatedFiles":["src/main/java/module-info.java","src/main/java/parameters/query/ConstantAsyncClient.java","src/main/java/parameters/query/ConstantClient.java","src/main/java/parameters/query/QueryClientBuilder.java","src/main/java/parameters/query/SpecialCharAsyncClient.java","src/main/java/parameters/query/SpecialCharClient.java","src/main/java/parameters/query/implementation/ConstantsImpl.java","src/main/java/parameters/query/implementation/QueryClientImpl.java","src/main/java/parameters/query/implementation/SpecialCharsImpl.java","src/main/java/parameters/query/implementation/package-info.java","src/main/java/parameters/query/package-info.java"]} \ No newline at end of file diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-inheritance-singlediscriminator_metadata.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-inheritance-singlediscriminator_metadata.json index a66af8cc696..9709b7e59e0 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-inheritance-singlediscriminator_metadata.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-inheritance-singlediscriminator_metadata.json @@ -1 +1 @@ -{"flavor":"Azure","apiVersions":{},"crossLanguagePackageId":"Type.Model.Inheritance.SingleDiscriminator","crossLanguageVersion":"301c4a3b5af0","crossLanguageDefinitions":{"type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient":"Type.Model.Inheritance.SingleDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getLegacyModel":"Type.Model.Inheritance.SingleDiscriminator.getLegacyModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getLegacyModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getLegacyModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getMissingDiscriminator":"Type.Model.Inheritance.SingleDiscriminator.getMissingDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getMissingDiscriminatorWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getMissingDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getModel":"Type.Model.Inheritance.SingleDiscriminator.getModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getRecursiveModel":"Type.Model.Inheritance.SingleDiscriminator.getRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getRecursiveModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getWrongDiscriminator":"Type.Model.Inheritance.SingleDiscriminator.getWrongDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getWrongDiscriminatorWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getWrongDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.putModel":"Type.Model.Inheritance.SingleDiscriminator.putModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.putModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.putModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.putRecursiveModel":"Type.Model.Inheritance.SingleDiscriminator.putRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.putRecursiveModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.putRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient":"Type.Model.Inheritance.SingleDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getLegacyModel":"Type.Model.Inheritance.SingleDiscriminator.getLegacyModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getLegacyModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getLegacyModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getMissingDiscriminator":"Type.Model.Inheritance.SingleDiscriminator.getMissingDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getMissingDiscriminatorWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getMissingDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getModel":"Type.Model.Inheritance.SingleDiscriminator.getModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getRecursiveModel":"Type.Model.Inheritance.SingleDiscriminator.getRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getRecursiveModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getWrongDiscriminator":"Type.Model.Inheritance.SingleDiscriminator.getWrongDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getWrongDiscriminatorWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getWrongDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.putModel":"Type.Model.Inheritance.SingleDiscriminator.putModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.putModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.putModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.putRecursiveModel":"Type.Model.Inheritance.SingleDiscriminator.putRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.putRecursiveModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.putRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClientBuilder":"Type.Model.Inheritance.SingleDiscriminator","type.model.inheritance.singlediscriminator.models.Bird":"Type.Model.Inheritance.SingleDiscriminator.Bird","type.model.inheritance.singlediscriminator.models.Dinosaur":"Type.Model.Inheritance.SingleDiscriminator.Dinosaur","type.model.inheritance.singlediscriminator.models.Eagle":"Type.Model.Inheritance.SingleDiscriminator.Eagle","type.model.inheritance.singlediscriminator.models.Goose":"Type.Model.Inheritance.SingleDiscriminator.Goose","type.model.inheritance.singlediscriminator.models.SeaGull":"Type.Model.Inheritance.SingleDiscriminator.SeaGull","type.model.inheritance.singlediscriminator.models.Sparrow":"Type.Model.Inheritance.SingleDiscriminator.Sparrow","type.model.inheritance.singlediscriminator.models.TRex":"Type.Model.Inheritance.SingleDiscriminator.TRex"},"generatedFiles":["src/main/java/module-info.java","src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorAsyncClient.java","src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java","src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClientBuilder.java","src/main/java/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java","src/main/java/type/model/inheritance/singlediscriminator/implementation/package-info.java","src/main/java/type/model/inheritance/singlediscriminator/models/Bird.java","src/main/java/type/model/inheritance/singlediscriminator/models/Dinosaur.java","src/main/java/type/model/inheritance/singlediscriminator/models/Eagle.java","src/main/java/type/model/inheritance/singlediscriminator/models/Goose.java","src/main/java/type/model/inheritance/singlediscriminator/models/SeaGull.java","src/main/java/type/model/inheritance/singlediscriminator/models/Sparrow.java","src/main/java/type/model/inheritance/singlediscriminator/models/TRex.java","src/main/java/type/model/inheritance/singlediscriminator/models/package-info.java","src/main/java/type/model/inheritance/singlediscriminator/package-info.java"]} \ No newline at end of file +{"flavor":"Azure","apiVersions":{},"crossLanguagePackageId":"Type.Model.Inheritance.SingleDiscriminator","crossLanguageVersion":"d008d2bf96fe","crossLanguageDefinitions":{"type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient":"Type.Model.Inheritance.SingleDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getLegacyModel":"Type.Model.Inheritance.SingleDiscriminator.getLegacyModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getLegacyModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getLegacyModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getMissingDiscriminator":"Type.Model.Inheritance.SingleDiscriminator.getMissingDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getMissingDiscriminatorWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getMissingDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getModel":"Type.Model.Inheritance.SingleDiscriminator.getModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getNoSubtypesModel":"Type.Model.Inheritance.SingleDiscriminator.getNoSubtypesModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getNoSubtypesModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getNoSubtypesModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getRecursiveModel":"Type.Model.Inheritance.SingleDiscriminator.getRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getRecursiveModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getWrongDiscriminator":"Type.Model.Inheritance.SingleDiscriminator.getWrongDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getWrongDiscriminatorWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getWrongDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.putModel":"Type.Model.Inheritance.SingleDiscriminator.putModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.putModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.putModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.putNoSubtypesModel":"Type.Model.Inheritance.SingleDiscriminator.putNoSubtypesModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.putNoSubtypesModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.putNoSubtypesModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.putRecursiveModel":"Type.Model.Inheritance.SingleDiscriminator.putRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.putRecursiveModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.putRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient":"Type.Model.Inheritance.SingleDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getLegacyModel":"Type.Model.Inheritance.SingleDiscriminator.getLegacyModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getLegacyModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getLegacyModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getMissingDiscriminator":"Type.Model.Inheritance.SingleDiscriminator.getMissingDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getMissingDiscriminatorWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getMissingDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getModel":"Type.Model.Inheritance.SingleDiscriminator.getModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getNoSubtypesModel":"Type.Model.Inheritance.SingleDiscriminator.getNoSubtypesModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getNoSubtypesModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getNoSubtypesModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getRecursiveModel":"Type.Model.Inheritance.SingleDiscriminator.getRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getRecursiveModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getWrongDiscriminator":"Type.Model.Inheritance.SingleDiscriminator.getWrongDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getWrongDiscriminatorWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getWrongDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.putModel":"Type.Model.Inheritance.SingleDiscriminator.putModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.putModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.putModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.putNoSubtypesModel":"Type.Model.Inheritance.SingleDiscriminator.putNoSubtypesModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.putNoSubtypesModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.putNoSubtypesModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.putRecursiveModel":"Type.Model.Inheritance.SingleDiscriminator.putRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.putRecursiveModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.putRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClientBuilder":"Type.Model.Inheritance.SingleDiscriminator","type.model.inheritance.singlediscriminator.models.Bird":"Type.Model.Inheritance.SingleDiscriminator.Bird","type.model.inheritance.singlediscriminator.models.Dinosaur":"Type.Model.Inheritance.SingleDiscriminator.Dinosaur","type.model.inheritance.singlediscriminator.models.Eagle":"Type.Model.Inheritance.SingleDiscriminator.Eagle","type.model.inheritance.singlediscriminator.models.Fish":"Type.Model.Inheritance.SingleDiscriminator.Fish","type.model.inheritance.singlediscriminator.models.Goose":"Type.Model.Inheritance.SingleDiscriminator.Goose","type.model.inheritance.singlediscriminator.models.SeaGull":"Type.Model.Inheritance.SingleDiscriminator.SeaGull","type.model.inheritance.singlediscriminator.models.Sparrow":"Type.Model.Inheritance.SingleDiscriminator.Sparrow","type.model.inheritance.singlediscriminator.models.TRex":"Type.Model.Inheritance.SingleDiscriminator.TRex"},"generatedFiles":["src/main/java/module-info.java","src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorAsyncClient.java","src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java","src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClientBuilder.java","src/main/java/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java","src/main/java/type/model/inheritance/singlediscriminator/implementation/package-info.java","src/main/java/type/model/inheritance/singlediscriminator/models/Bird.java","src/main/java/type/model/inheritance/singlediscriminator/models/Dinosaur.java","src/main/java/type/model/inheritance/singlediscriminator/models/Eagle.java","src/main/java/type/model/inheritance/singlediscriminator/models/Fish.java","src/main/java/type/model/inheritance/singlediscriminator/models/Goose.java","src/main/java/type/model/inheritance/singlediscriminator/models/SeaGull.java","src/main/java/type/model/inheritance/singlediscriminator/models/Sparrow.java","src/main/java/type/model/inheritance/singlediscriminator/models/TRex.java","src/main/java/type/model/inheritance/singlediscriminator/models/package-info.java","src/main/java/type/model/inheritance/singlediscriminator/package-info.java"]} \ No newline at end of file diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/azure-resourcemanager-managementgroup-generated.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/azure-resourcemanager-managementgroup-generated.properties new file mode 100644 index 00000000000..defbd48204e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/azure-resourcemanager-managementgroup-generated.properties @@ -0,0 +1 @@ +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/parameters-bodyroot.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/parameters-bodyroot.properties new file mode 100644 index 00000000000..ca812989b4f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/parameters-bodyroot.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/azure/resourcemanager/commonproperties/CommonPropertiesTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/azure/resourcemanager/commonproperties/CommonPropertiesTests.java index bb7878993ad..11cccea7fb1 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/test/java/azure/resourcemanager/commonproperties/CommonPropertiesTests.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/azure/resourcemanager/commonproperties/CommonPropertiesTests.java @@ -4,11 +4,14 @@ package azure.resourcemanager.commonproperties; import azure.resourcemanager.commonproperties.models.ApiErrorException; +import azure.resourcemanager.commonproperties.models.ArmResourceIdentifierResource; +import azure.resourcemanager.commonproperties.models.ArmResourceIdentifierResourceProperties; import azure.resourcemanager.commonproperties.models.ConfidentialResourceProperties; import azure.resourcemanager.commonproperties.models.ManagedIdentityTrackedResource; import azure.resourcemanager.commonproperties.models.ManagedIdentityTrackedResourceProperties; import azure.resourcemanager.commonproperties.models.ManagedServiceIdentity; import azure.resourcemanager.commonproperties.models.ManagedServiceIdentityType; +import azure.resourcemanager.commonproperties.models.ResourceProvisioningState; import azure.resourcemanager.commonproperties.models.UserAssignedIdentity; import com.azure.core.management.Region; import com.azure.core.management.exception.ManagementException; @@ -91,4 +94,42 @@ public void testError() { Assertions.assertNotNull(exception); Assertions.assertEquals("ResourceNotFound", exception.getValue().getCode()); } + + @Test + public void testArmResourceIdentifiers() { + final String subscriptionId = "00000000-0000-0000-0000-000000000000"; + final String resourceGroup = "test-rg"; + final String simpleArmId = "/subscriptions/" + subscriptionId + "/resourceGroups/" + resourceGroup + + "/providers/Microsoft.Network/virtualNetworks/myVnet"; + final String armIdWithAllScopes = "/subscriptions/" + subscriptionId + "/resourceGroups/" + resourceGroup + + "/providers/Microsoft.Compute/virtualMachines/myVm"; + + // Create + ArmResourceIdentifierResource resource = manager.armResourceIdentifiers() + .define("armId") + .withRegion(Region.US_EAST) + .withExistingResourceGroup(resourceGroup) + .withProperties(new ArmResourceIdentifierResourceProperties().withSimpleArmId(simpleArmId) + .withArmIdWithType(simpleArmId) + .withArmIdWithTypeAndScope(simpleArmId) + .withArmIdWithAllScopes(armIdWithAllScopes)) + .create(); + Assertions.assertNotNull(resource); + Assertions.assertEquals("armId", resource.name()); + Assertions.assertNotNull(resource.properties()); + Assertions.assertEquals(ResourceProvisioningState.SUCCEEDED, resource.properties().provisioningState()); + Assertions.assertEquals(simpleArmId, resource.properties().simpleArmId()); + Assertions.assertEquals(simpleArmId, resource.properties().armIdWithType()); + Assertions.assertEquals(simpleArmId, resource.properties().armIdWithTypeAndScope()); + Assertions.assertEquals(armIdWithAllScopes, resource.properties().armIdWithAllScopes()); + + // Get + resource = manager.armResourceIdentifiers().getByResourceGroup(resourceGroup, "armId"); + Assertions.assertNotNull(resource); + Assertions.assertEquals("armId", resource.name()); + Assertions.assertNotNull(resource.properties()); + Assertions.assertEquals(ResourceProvisioningState.SUCCEEDED, resource.properties().provisioningState()); + Assertions.assertEquals(simpleArmId, resource.properties().simpleArmId()); + Assertions.assertEquals(armIdWithAllScopes, resource.properties().armIdWithAllScopes()); + } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/azure/resourcemanager/managementgroup/ManagementGroupTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/azure/resourcemanager/managementgroup/ManagementGroupTests.java new file mode 100644 index 00000000000..0c5a0e6a8cd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/azure/resourcemanager/managementgroup/ManagementGroupTests.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package azure.resourcemanager.managementgroup; + +import azure.resourcemanager.managementgroup.fluent.models.ManagementGroupChildResourceInner; +import azure.resourcemanager.managementgroup.models.ManagementGroupChildResource; +import azure.resourcemanager.managementgroup.models.ManagementGroupChildResourceProperties; +import azure.resourcemanager.managementgroup.models.ProvisioningState; +import java.util.List; +import java.util.stream.Collectors; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.utils.ArmUtils; + +public class ManagementGroupTests { + + private static final String MANAGEMENT_GROUP_ID = "test-mg"; + private static final String RESOURCE_NAME = "resource"; + private static final String RESOURCE_TYPE = "Microsoft.ManagementGroupChild/managementGroupChildResources"; + private static final String RESOURCE_DESCRIPTION_VALID = "valid"; + private static final String RESOURCE_DESCRIPTION_VALID2 = "valid2"; + + private final ManagementGroupManager manager + = ManagementGroupManager.authenticate(ArmUtils.createTestHttpPipeline(), ArmUtils.getAzureProfile()); + + @Test + public void testGet() { + ManagementGroupChildResource resource + = manager.managementGroupChildResources().get(MANAGEMENT_GROUP_ID, RESOURCE_NAME); + Assertions.assertNotNull(resource); + Assertions.assertEquals(RESOURCE_NAME, resource.name()); + Assertions.assertEquals(RESOURCE_TYPE, resource.type()); + Assertions.assertNotNull(resource.properties()); + Assertions.assertEquals(RESOURCE_DESCRIPTION_VALID, resource.properties().description()); + Assertions.assertEquals(ProvisioningState.SUCCEEDED, resource.properties().provisioningState()); + } + + @Test + public void testCreateOrUpdate() { + ManagementGroupChildResource resource = manager.managementGroupChildResources() + .createOrUpdate(MANAGEMENT_GROUP_ID, RESOURCE_NAME, new ManagementGroupChildResourceInner().withProperties( + new ManagementGroupChildResourceProperties().withDescription(RESOURCE_DESCRIPTION_VALID))); + Assertions.assertNotNull(resource); + Assertions.assertEquals(RESOURCE_NAME, resource.name()); + Assertions.assertEquals(RESOURCE_TYPE, resource.type()); + Assertions.assertNotNull(resource.properties()); + Assertions.assertEquals(RESOURCE_DESCRIPTION_VALID, resource.properties().description()); + Assertions.assertEquals(ProvisioningState.SUCCEEDED, resource.properties().provisioningState()); + } + + @Test + public void testUpdate() { + ManagementGroupChildResource resource = manager.managementGroupChildResources() + .update(MANAGEMENT_GROUP_ID, RESOURCE_NAME, new ManagementGroupChildResourceInner().withProperties( + new ManagementGroupChildResourceProperties().withDescription(RESOURCE_DESCRIPTION_VALID2))); + Assertions.assertNotNull(resource); + Assertions.assertEquals(RESOURCE_NAME, resource.name()); + Assertions.assertNotNull(resource.properties()); + Assertions.assertEquals(RESOURCE_DESCRIPTION_VALID2, resource.properties().description()); + Assertions.assertEquals(ProvisioningState.SUCCEEDED, resource.properties().provisioningState()); + } + + @Test + public void testDelete() { + manager.managementGroupChildResources().deleteByResourceGroup(MANAGEMENT_GROUP_ID, RESOURCE_NAME); + } + + @Test + public void testListByManagementGroup() { + List resources = manager.managementGroupChildResources() + .listByManagementGroup(MANAGEMENT_GROUP_ID) + .stream() + .collect(Collectors.toList()); + Assertions.assertEquals(1, resources.size()); + ManagementGroupChildResource resource = resources.get(0); + Assertions.assertNotNull(resource); + Assertions.assertEquals(RESOURCE_NAME, resource.name()); + Assertions.assertEquals(RESOURCE_TYPE, resource.type()); + Assertions.assertNotNull(resource.properties()); + Assertions.assertEquals(RESOURCE_DESCRIPTION_VALID, resource.properties().description()); + Assertions.assertEquals(ProvisioningState.SUCCEEDED, resource.properties().provisioningState()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/bodyroot/BodyRootTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/bodyroot/BodyRootTests.java new file mode 100644 index 00000000000..95087f9a002 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/bodyroot/BodyRootTests.java @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package parameters.bodyroot; + +import org.junit.jupiter.api.Test; +import parameters.bodyroot.models.BodyRootModel; + +public class BodyRootTests { + + private final BodyRootClient client = new BodyRootClientBuilder().buildClient(); + + @Test + public void testNested() { + client.nested(new BodyRootModel().setCategory("widget").setLinkType("hard").setWasSuccessful(true)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/bodyroot/generated/BodyRootClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/bodyroot/generated/BodyRootClientTestBase.java new file mode 100644 index 00000000000..935e88983c5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/bodyroot/generated/BodyRootClientTestBase.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.bodyroot.generated; + +// The Java test files under 'generated' package are generated for your reference. +// If you wish to modify these files, please copy them out of the 'generated' package, and modify there. +// See https://aka.ms/azsdk/dpg/java/tests for guide on adding a test. + +import com.azure.core.http.policy.HttpLogDetailLevel; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.test.TestMode; +import com.azure.core.test.TestProxyTestBase; +import com.azure.core.util.Configuration; +import parameters.bodyroot.BodyRootClient; +import parameters.bodyroot.BodyRootClientBuilder; + +class BodyRootClientTestBase extends TestProxyTestBase { + protected BodyRootClient bodyRootClient; + + @Override + protected void beforeTest() { + BodyRootClientBuilder bodyRootClientbuilder = new BodyRootClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.RECORD) { + bodyRootClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + bodyRootClient = bodyRootClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/query/QueryTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/query/QueryTests.java index 34823dfd15d..8f512938876 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/query/QueryTests.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/query/QueryTests.java @@ -3,14 +3,22 @@ package parameters.query; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; public class QueryTests { - private final QueryClient client = new QueryClientBuilder().buildClient(); + private final ConstantClient constantClient = new QueryClientBuilder().buildConstantClient(); + private final SpecialCharClient specialCharClient = new QueryClientBuilder().buildSpecialCharClient(); @Test public void testConstant() { - client.post(); + constantClient.post(); + } + + @Test + @Disabled("Blocked until @typespec/http-specs publishes the dollar-sign route fix") + public void testDollarSign() { + specialCharClient.dollarSign("status eq 'active'"); } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/query/generated/QueryClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/query/generated/QueryClientTestBase.java index a44b9453f61..b16439abbc9 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/query/generated/QueryClientTestBase.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/query/generated/QueryClientTestBase.java @@ -13,22 +13,34 @@ import com.azure.core.test.TestMode; import com.azure.core.test.TestProxyTestBase; import com.azure.core.util.Configuration; -import parameters.query.QueryClient; +import parameters.query.ConstantClient; import parameters.query.QueryClientBuilder; +import parameters.query.SpecialCharClient; class QueryClientTestBase extends TestProxyTestBase { - protected QueryClient queryClient; + protected ConstantClient constantClient; + + protected SpecialCharClient specialCharClient; @Override protected void beforeTest() { - QueryClientBuilder queryClientbuilder = new QueryClientBuilder() + QueryClientBuilder constantClientbuilder = new QueryClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.RECORD) { + constantClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + constantClient = constantClientbuilder.buildConstantClient(); + + QueryClientBuilder specialCharClientbuilder = new QueryClientBuilder() .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); if (getTestMode() == TestMode.RECORD) { - queryClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + specialCharClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); } - queryClient = queryClientbuilder.buildClient(); + specialCharClient = specialCharClientbuilder.buildSpecialCharClient(); } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/type/model/inheritance/SingleDiscriminatorTest.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/type/model/inheritance/SingleDiscriminatorTest.java index 0aba3bf2f3d..552b4227335 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/test/java/type/model/inheritance/SingleDiscriminatorTest.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/type/model/inheritance/SingleDiscriminatorTest.java @@ -9,6 +9,7 @@ import type.model.inheritance.singlediscriminator.SingleDiscriminatorClientBuilder; import type.model.inheritance.singlediscriminator.models.Bird; import type.model.inheritance.singlediscriminator.models.Eagle; +import type.model.inheritance.singlediscriminator.models.Fish; import type.model.inheritance.singlediscriminator.models.Goose; import type.model.inheritance.singlediscriminator.models.SeaGull; import type.model.inheritance.singlediscriminator.models.Sparrow; @@ -36,4 +37,13 @@ public void testSingleDiscriminator() { Assertions.assertEquals(Sparrow.class, recursiveModel.getHate().get("key3").getClass()); client.putRecursiveModel(recursiveModel); } + + @Test + public void testNoSubtypesModel() { + Fish fish = client.getNoSubtypesModel(); + Assertions.assertNotNull(fish); + Assertions.assertEquals(10, fish.getSize()); + + client.putNoSubtypesModel(fish); + } } diff --git a/packages/http-client-java/package-lock.json b/packages/http-client-java/package-lock.json index 95538252fb7..58b51c2a3db 100644 --- a/packages/http-client-java/package-lock.json +++ b/packages/http-client-java/package-lock.json @@ -1,12 +1,12 @@ { "name": "@typespec/http-client-java", - "version": "0.8.1", + "version": "0.9.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@typespec/http-client-java", - "version": "0.8.1", + "version": "0.9.0", "license": "MIT", "dependencies": { "@autorest/codemodel": "~4.20.1", @@ -14,26 +14,26 @@ "lodash": "~4.18.1" }, "devDependencies": { - "@azure-tools/typespec-autorest": "0.68.0", - "@azure-tools/typespec-azure-core": "0.68.0", - "@azure-tools/typespec-azure-resource-manager": "0.68.0", - "@azure-tools/typespec-azure-rulesets": "0.68.0", - "@azure-tools/typespec-client-generator-core": "0.68.4", + "@azure-tools/typespec-autorest": "0.69.0", + "@azure-tools/typespec-azure-core": "0.69.0", + "@azure-tools/typespec-azure-resource-manager": "0.69.0", + "@azure-tools/typespec-azure-rulesets": "0.69.0", + "@azure-tools/typespec-client-generator-core": "0.69.0", "@microsoft/api-extractor": "^7.58.8", "@microsoft/api-extractor-model": "^7.33.8", "@types/js-yaml": "~4.0.9", "@types/lodash": "~4.17.24", "@types/node": "~25.9.2", - "@typespec/compiler": "1.12.0", - "@typespec/events": "0.82.0", - "@typespec/http": "1.12.0", - "@typespec/openapi": "1.12.0", - "@typespec/rest": "0.82.0", + "@typespec/compiler": "1.13.0", + "@typespec/events": "0.83.0", + "@typespec/http": "1.13.0", + "@typespec/openapi": "1.13.0", + "@typespec/rest": "0.83.0", "@typespec/spector": "0.1.0-alpha.25", - "@typespec/sse": "0.82.0", - "@typespec/streams": "0.82.0", - "@typespec/versioning": "0.82.0", - "@typespec/xml": "0.82.0", + "@typespec/sse": "0.83.0", + "@typespec/streams": "0.83.0", + "@typespec/versioning": "0.83.0", + "@typespec/xml": "0.83.0", "@vitest/coverage-v8": "^4.1.8", "@vitest/ui": "^4.1.8", "c8": "~11.0.0", @@ -45,19 +45,19 @@ "node": ">=20.0.0" }, "peerDependencies": { - "@azure-tools/typespec-autorest": ">=0.68.0 <1.0.0", - "@azure-tools/typespec-azure-core": ">=0.68.0 <1.0.0", - "@azure-tools/typespec-azure-resource-manager": ">=0.68.0 <1.0.0", - "@azure-tools/typespec-client-generator-core": ">=0.68.0 <1.0.0", - "@typespec/compiler": "^1.12.0", - "@typespec/events": ">=0.82.0 <1.0.0", - "@typespec/http": "^1.12.0", - "@typespec/openapi": "^1.12.0", - "@typespec/rest": ">=0.82.0 <1.0.0", - "@typespec/sse": ">=0.82.0 <1.0.0", - "@typespec/streams": ">=0.82.0 <1.0.0", - "@typespec/versioning": ">=0.82.0 <1.0.0", - "@typespec/xml": ">=0.82.0 <1.0.0" + "@azure-tools/typespec-autorest": ">=0.69.0 <1.0.0", + "@azure-tools/typespec-azure-core": ">=0.69.0 <1.0.0", + "@azure-tools/typespec-azure-resource-manager": ">=0.69.0 <1.0.0", + "@azure-tools/typespec-client-generator-core": ">=0.69.0 <1.0.0", + "@typespec/compiler": "^1.13.0", + "@typespec/events": ">=0.83.0 <1.0.0", + "@typespec/http": "^1.13.0", + "@typespec/openapi": "^1.13.0", + "@typespec/rest": ">=0.83.0 <1.0.0", + "@typespec/sse": ">=0.83.0 <1.0.0", + "@typespec/streams": ">=0.83.0 <1.0.0", + "@typespec/versioning": ">=0.83.0 <1.0.0", + "@typespec/xml": ">=0.83.0 <1.0.0" } }, "node_modules/@autorest/codemodel": { @@ -134,24 +134,24 @@ } }, "node_modules/@azure-tools/typespec-autorest": { - "version": "0.68.0", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-autorest/-/typespec-autorest-0.68.0.tgz", - "integrity": "sha512-ywcB68x0jOuplKg1u9ZpjOamHbIEEgAaMuXTP72cvWXE7q1eGLCN1DQx1Uk5ME8VLJKAX6cMOMHK4hcmg9tvuw==", + "version": "0.69.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-autorest/-/typespec-autorest-0.69.0.tgz", + "integrity": "sha512-6lOOe3NWfLI8M5NGLM1ZzIFRe34gVPj2GXzti9ag6o3fVpC6eMUfacv1sU4zmz9dkpKTdOUXNO5qm3DvqPRC8Q==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": "^0.68.0", - "@azure-tools/typespec-azure-resource-manager": "^0.68.0", - "@azure-tools/typespec-client-generator-core": "^0.68.0", - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0", - "@typespec/openapi": "^1.12.0", - "@typespec/rest": "^0.82.0", - "@typespec/versioning": "^0.82.0", - "@typespec/xml": "^0.82.0" + "@azure-tools/typespec-azure-core": "^0.69.0", + "@azure-tools/typespec-azure-resource-manager": "^0.69.0", + "@azure-tools/typespec-client-generator-core": "^0.69.0", + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0", + "@typespec/openapi": "^1.13.0", + "@typespec/rest": "^0.83.0", + "@typespec/versioning": "^0.83.0", + "@typespec/xml": "^0.83.0" }, "peerDependenciesMeta": { "@typespec/xml": { @@ -160,24 +160,24 @@ } }, "node_modules/@azure-tools/typespec-azure-core": { - "version": "0.68.0", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-core/-/typespec-azure-core-0.68.0.tgz", - "integrity": "sha512-p0qUkRZav5fdQvGe2gSCvlgsvpM0y9xVhgH2GpXi5ZzpYfNGzxd8oZr8VOCP8mjMVfGQ3AtnowbmrHALEZgz7Q==", + "version": "0.69.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-core/-/typespec-azure-core-0.69.0.tgz", + "integrity": "sha512-UNdPb/DgMvXqwWk9hb54QOAumCJ6u6GGy+bj3RIIT1Sht6FR9rIn8AQ/UQ7WtrhbJBoqvQo5dxtS565a9/VRZw==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0", - "@typespec/rest": "^0.82.0" + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0", + "@typespec/rest": "^0.83.0" } }, "node_modules/@azure-tools/typespec-azure-resource-manager": { - "version": "0.68.0", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-resource-manager/-/typespec-azure-resource-manager-0.68.0.tgz", - "integrity": "sha512-1zgXpOb/fGfB7SrFqawKasSOTIi9cZPWyK8V3RHyNWFZVQclEMGBzSvBHi6an4AEChqcjCSMh5MEr4BSujW4Ew==", + "version": "0.69.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-resource-manager/-/typespec-azure-resource-manager-0.69.0.tgz", + "integrity": "sha512-q/kdsGhVpvn2wb3OedxFHg7hp+al3FynUAPsz2gwqJx62z6UGOEJhtYCWP3osatVgxvKRhhh8uYl5mHRMDFi3g==", "dev": true, "license": "MIT", "dependencies": { @@ -188,34 +188,34 @@ "node": ">=22.0.0" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": "^0.68.0", - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0", - "@typespec/openapi": "^1.12.0", - "@typespec/rest": "^0.82.0", - "@typespec/versioning": "^0.82.0" + "@azure-tools/typespec-azure-core": "^0.69.0", + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0", + "@typespec/openapi": "^1.13.0", + "@typespec/rest": "^0.83.0", + "@typespec/versioning": "^0.83.0" } }, "node_modules/@azure-tools/typespec-azure-rulesets": { - "version": "0.68.0", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-rulesets/-/typespec-azure-rulesets-0.68.0.tgz", - "integrity": "sha512-cXZ3jiDNqJgpBQLguNgXjvAsvYo7VwtlQxFMzTr96gpoAiuBViH+3eOhVd5HA4H96NgAWSddTMHXZJZzcsnE5A==", + "version": "0.69.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-rulesets/-/typespec-azure-rulesets-0.69.0.tgz", + "integrity": "sha512-+7KThtfHupWBDSwDR9rRHNmBb15gxACH8iPOOohRr1J28Gu25YWlz1G00r62X9VUBFLZTxYc4rQ2QCxPFT0uFw==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": "^0.68.0", - "@azure-tools/typespec-azure-resource-manager": "^0.68.0", - "@azure-tools/typespec-client-generator-core": "^0.68.0", - "@typespec/compiler": "^1.12.0" + "@azure-tools/typespec-azure-core": "^0.69.0", + "@azure-tools/typespec-azure-resource-manager": "^0.69.0", + "@azure-tools/typespec-client-generator-core": "^0.69.0", + "@typespec/compiler": "^1.13.0" } }, "node_modules/@azure-tools/typespec-client-generator-core": { - "version": "0.68.4", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-client-generator-core/-/typespec-client-generator-core-0.68.4.tgz", - "integrity": "sha512-p32EXsrSC9giZUNdsQ2gmvDENFIEW2E0zto3FmjBZ3OeB5wCw1ZAZ+KnO0rsoKFovBvHSsQatNCKJvM/x89AgA==", + "version": "0.69.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-client-generator-core/-/typespec-client-generator-core-0.69.0.tgz", + "integrity": "sha512-ro8zzOeiN/74r0wM19R77gzLtbfjIFgKgr1Rusii/vhCfJIoVC7IcqLxhbJl0RVkjyhRFKt4GCRAw4iurnrDnw==", "dev": true, "license": "MIT", "dependencies": { @@ -227,16 +227,16 @@ "node": ">=22.0.0" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": "^0.68.0", - "@typespec/compiler": "^1.12.0", - "@typespec/events": "^0.82.0", - "@typespec/http": "^1.12.0", - "@typespec/openapi": "^1.12.0", - "@typespec/rest": "^0.82.0", - "@typespec/sse": "^0.82.0", - "@typespec/streams": "^0.82.0", - "@typespec/versioning": "^0.82.0", - "@typespec/xml": "^0.82.0" + "@azure-tools/typespec-azure-core": "^0.69.0", + "@typespec/compiler": "^1.13.0", + "@typespec/events": "^0.83.0", + "@typespec/http": "^1.13.0", + "@typespec/openapi": "^1.13.0", + "@typespec/rest": "^0.83.0", + "@typespec/sse": "^0.83.0", + "@typespec/streams": "^0.83.0", + "@typespec/versioning": "^0.83.0", + "@typespec/xml": "^0.83.0" } }, "node_modules/@azure/abort-controller": { @@ -1659,9 +1659,9 @@ "license": "MIT" }, "node_modules/@typespec/compiler": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/@typespec/compiler/-/compiler-1.12.0.tgz", - "integrity": "sha512-hKCkHEEDdCpXFyOU8ln+TzBBwonFMbkeUV0zIc+vBETyO8p/Upui3XvEyLOyB4CpKUReHzGeGm3gcFjNc73ygg==", + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/@typespec/compiler/-/compiler-1.13.0.tgz", + "integrity": "sha512-DonoHiyAMx0UjSmssqTrFtya+v97wny1aHcTLU5QF2wFzLATtcwUU9hbPC+eXhepuTunMOCHf8yk3pEsH6PZYA==", "dev": true, "license": "MIT", "dependencies": { @@ -1819,30 +1819,30 @@ } }, "node_modules/@typespec/events": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/events/-/events-0.82.0.tgz", - "integrity": "sha512-4gxwWndMVmYF6e5ETrwW6b77h1DsSc2ZiIbNo98XePaynD6yz/ooHKKtNKacjC2gmWhfRz1ArPioYn0YHvQkxw==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/events/-/events-0.83.0.tgz", + "integrity": "sha512-3EP1EIjdLgwStgd2rGWaF/QqY7YRAt+DIYnnYG2VsdPwa8s2t6K6eJ9YJDXveeHImAkHs+cpFuwxnjKMl4hOyw==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0" + "@typespec/compiler": "^1.13.0" } }, "node_modules/@typespec/http": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/@typespec/http/-/http-1.12.0.tgz", - "integrity": "sha512-3Bb1M6VSuEVPWOecXj3h3I/ddMpb9cmKRQQq34oq7LatiK4fwVBp+EdWbqzEzaRUGHm9mZtqsMsxZf5FndT8dg==", + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/@typespec/http/-/http-1.13.0.tgz", + "integrity": "sha512-tf8XFddU6g1MZSAVCLC/0Xa4fNfUO0CcHe6PWpmC3bvUojxMnpRcERI2DdoRJ+aycB9Q+Z8wN8bJO3up6u+sCw==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0", - "@typespec/streams": "^0.82.0" + "@typespec/compiler": "^1.13.0", + "@typespec/streams": "^0.83.0" }, "peerDependenciesMeta": { "@typespec/streams": { @@ -1851,31 +1851,31 @@ } }, "node_modules/@typespec/openapi": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/@typespec/openapi/-/openapi-1.12.0.tgz", - "integrity": "sha512-XtkCMPpzXFfuIzmx/BQrCMUCCk7d37lkqZe5ubJmvJ02Fr7yvAbofrgtNUZ1BbFe3TBBUS2nB3E3mjT3tE4zCQ==", + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/@typespec/openapi/-/openapi-1.13.0.tgz", + "integrity": "sha512-omPc9n+LM2WvjYwnIf31RCxmG17fFUOVLBRsWg4T1mbcsNCj4grnNP7Lwt+irIZCiKtmLKxq3ViE7jYixCkZ3g==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0" + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0" } }, "node_modules/@typespec/rest": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/rest/-/rest-0.82.0.tgz", - "integrity": "sha512-cKjKEd8lgE3EdU9b5xXLoSdKBcifITOhHS2n9LPbEG9w6APfWDWGdtUe4UKV3wxWq9HlT143wpECW7IjrPhjnA==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/rest/-/rest-0.83.0.tgz", + "integrity": "sha512-WMEwEe1kdaOdZ0c+ct5BVmTSBXkrPniUYDWCz3K52T4in2dNc7J6YGP6tL8bXgQz5B0CsP0VNO12N+UysQDsLw==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0" + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0" } }, "node_modules/@typespec/spec-api": { @@ -2111,32 +2111,32 @@ } }, "node_modules/@typespec/sse": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/sse/-/sse-0.82.0.tgz", - "integrity": "sha512-4jBByfLsS7yQAIqmbLkfrw4XoPm9kOqawvW5gVXmKtnMMDYR0RmfBhsnAXBqhUXGbnFq0bDJGEw3GX+6k3mKnA==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/sse/-/sse-0.83.0.tgz", + "integrity": "sha512-04WNaju2rwBbcF5pG+HrKQtdcrmSGuTVziLHNA9XOqj1qM7Uon3+wo2g+ZZ3Z6tngfqQoTCPyDcRHqZtGRdNuw==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0", - "@typespec/events": "^0.82.0", - "@typespec/http": "^1.12.0", - "@typespec/streams": "^0.82.0" + "@typespec/compiler": "^1.13.0", + "@typespec/events": "^0.83.0", + "@typespec/http": "^1.13.0", + "@typespec/streams": "^0.83.0" } }, "node_modules/@typespec/streams": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/streams/-/streams-0.82.0.tgz", - "integrity": "sha512-cr/6h6VV/6OJeG8RNcSd0SDes5iEXiuGUcKGrMN6wF8qKTTrY2hXNhfqCCn3lamDOg00wbi7ke+laz6pHWN3tg==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/streams/-/streams-0.83.0.tgz", + "integrity": "sha512-wbO6sdH1Uf+UwjxxsWdHQkjJ3wwiYsAKI+L66qnDYVXAFe02sUdMKd0mxH5o9ipGXE52MZ+yvZ52vHAD+g3RFQ==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0" + "@typespec/compiler": "^1.13.0" } }, "node_modules/@typespec/ts-http-runtime": { @@ -2155,29 +2155,29 @@ } }, "node_modules/@typespec/versioning": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/versioning/-/versioning-0.82.0.tgz", - "integrity": "sha512-s8giuYQTQPniy2YxNfKXYpAU2Vm4L74TdOsbFWe0tG+jnOy/9tt7kKTH4QF1sB8nRvmjv8h31EoHtZYOPe1GvA==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/versioning/-/versioning-0.83.0.tgz", + "integrity": "sha512-nE66ta0ixpHB6FQpSzqnj8QnVfgFsxeK/4Xv+DxYx2nB/w18f6VjkF+hW+A/zs1tZIYvBZVbCNa/Rcr8zM6fhg==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0" + "@typespec/compiler": "^1.13.0" } }, "node_modules/@typespec/xml": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/xml/-/xml-0.82.0.tgz", - "integrity": "sha512-/Bwlt7HwSltojSbalkh7hGRh/lB5aMJllnb7gAAf3xRPMlnmu5VJqDFFcbZKqDvkwgGXZX/xHo458c4kott5Ug==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/xml/-/xml-0.83.0.tgz", + "integrity": "sha512-2/dtAD8jGPkIdwpQ1G1P+5+qdMPeafQiIKCd8NdAnOo0w9OZ59Io52jINm9HdN8+FcbOrqK8+B2N9rlPRj7PqA==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0" + "@typespec/compiler": "^1.13.0" } }, "node_modules/@vitest/coverage-v8": { diff --git a/packages/http-client-java/package.json b/packages/http-client-java/package.json index 1fb9c122bd6..01ea582a38c 100644 --- a/packages/http-client-java/package.json +++ b/packages/http-client-java/package.json @@ -1,6 +1,6 @@ { "name": "@typespec/http-client-java", - "version": "0.8.1", + "version": "0.9.0", "description": "TypeSpec library for emitting Java client from the TypeSpec REST protocol binding", "keywords": [ "TypeSpec" @@ -49,19 +49,19 @@ "generator/http-client-generator/target/classes/PerfAutomation.jfc" ], "peerDependencies": { - "@azure-tools/typespec-autorest": ">=0.68.0 <1.0.0", - "@azure-tools/typespec-azure-core": ">=0.68.0 <1.0.0", - "@azure-tools/typespec-azure-resource-manager": ">=0.68.0 <1.0.0", - "@azure-tools/typespec-client-generator-core": ">=0.68.0 <1.0.0", - "@typespec/compiler": "^1.12.0", - "@typespec/events": ">=0.82.0 <1.0.0", - "@typespec/http": "^1.12.0", - "@typespec/openapi": "^1.12.0", - "@typespec/rest": ">=0.82.0 <1.0.0", - "@typespec/sse": ">=0.82.0 <1.0.0", - "@typespec/streams": ">=0.82.0 <1.0.0", - "@typespec/versioning": ">=0.82.0 <1.0.0", - "@typespec/xml": ">=0.82.0 <1.0.0" + "@azure-tools/typespec-autorest": ">=0.69.0 <1.0.0", + "@azure-tools/typespec-azure-core": ">=0.69.0 <1.0.0", + "@azure-tools/typespec-azure-resource-manager": ">=0.69.0 <1.0.0", + "@azure-tools/typespec-client-generator-core": ">=0.69.0 <1.0.0", + "@typespec/compiler": "^1.13.0", + "@typespec/events": ">=0.83.0 <1.0.0", + "@typespec/http": "^1.13.0", + "@typespec/openapi": "^1.13.0", + "@typespec/rest": ">=0.83.0 <1.0.0", + "@typespec/sse": ">=0.83.0 <1.0.0", + "@typespec/streams": ">=0.83.0 <1.0.0", + "@typespec/versioning": ">=0.83.0 <1.0.0", + "@typespec/xml": ">=0.83.0 <1.0.0" }, "dependencies": { "@autorest/codemodel": "~4.20.1", @@ -69,26 +69,26 @@ "lodash": "~4.18.1" }, "devDependencies": { - "@azure-tools/typespec-autorest": "0.68.0", - "@azure-tools/typespec-azure-core": "0.68.0", - "@azure-tools/typespec-azure-resource-manager": "0.68.0", - "@azure-tools/typespec-azure-rulesets": "0.68.0", - "@azure-tools/typespec-client-generator-core": "0.68.4", + "@azure-tools/typespec-autorest": "0.69.0", + "@azure-tools/typespec-azure-core": "0.69.0", + "@azure-tools/typespec-azure-resource-manager": "0.69.0", + "@azure-tools/typespec-azure-rulesets": "0.69.0", + "@azure-tools/typespec-client-generator-core": "0.69.0", "@microsoft/api-extractor": "^7.58.8", "@microsoft/api-extractor-model": "^7.33.8", "@types/js-yaml": "~4.0.9", "@types/lodash": "~4.17.24", "@types/node": "~25.9.2", - "@typespec/compiler": "1.12.0", - "@typespec/events": "0.82.0", - "@typespec/http": "1.12.0", - "@typespec/openapi": "1.12.0", - "@typespec/rest": "0.82.0", + "@typespec/compiler": "1.13.0", + "@typespec/events": "0.83.0", + "@typespec/http": "1.13.0", + "@typespec/openapi": "1.13.0", + "@typespec/rest": "0.83.0", "@typespec/spector": "0.1.0-alpha.25", - "@typespec/sse": "0.82.0", - "@typespec/streams": "0.82.0", - "@typespec/versioning": "0.82.0", - "@typespec/xml": "0.82.0", + "@typespec/sse": "0.83.0", + "@typespec/streams": "0.83.0", + "@typespec/versioning": "0.83.0", + "@typespec/xml": "0.83.0", "@vitest/coverage-v8": "^4.1.8", "@vitest/ui": "^4.1.8", "c8": "~11.0.0", diff --git a/packages/http-client-python/CHANGELOG.md b/packages/http-client-python/CHANGELOG.md index 9bc37e53db5..c07dbe104c3 100644 --- a/packages/http-client-python/CHANGELOG.md +++ b/packages/http-client-python/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log - @typespec/http-client-python +## 0.31.1 + +### Bump dependencies + +- Bump dependencies of `@typespec/*` and `@azure-tools/*` to latest versions + ## 0.31.0 ### Features diff --git a/packages/http-client-python/emitter/src/emitter.ts b/packages/http-client-python/emitter/src/emitter.ts index 3ecd85c5f57..0208795e024 100644 --- a/packages/http-client-python/emitter/src/emitter.ts +++ b/packages/http-client-python/emitter/src/emitter.ts @@ -1,24 +1,17 @@ import { createSdkContext } from "@azure-tools/typespec-client-generator-core"; import { EmitContext, emitFile, joinPaths, NoTarget } from "@typespec/compiler"; -import { execSync } from "child_process"; -import fs from "fs"; import jsyaml from "js-yaml"; -import os from "os"; -import path, { dirname } from "path"; -import { loadPyodide, PyodideInterface } from "pyodide"; -import { fileURLToPath } from "url"; import pkgJson from "../../package.json" with { type: "json" }; import { emitCodeModel } from "./code-model.js"; import { - blackExcludeDirs, BLOB_STORAGE_BASE_URL, PACKAGE_NAME, PYGEN_WHEEL_FILENAME, PYODIDE_VERSION, } from "./constants.js"; -import { saveCodeModelAsYaml } from "./external-process.js"; import { PythonEmitterOptions, PythonSdkContext, reportDiagnostic } from "./lib.js"; -import { runPython3 } from "./run-python3.js"; +import { runNodeEmit } from "./node-runner.js"; +import { loadPyodide, PyodideInterface } from "./pyodide-loader.js"; import { getRootNamespace, md2Rst } from "./utils.js"; function getBrowserPygenWheelUrl(): string { @@ -193,7 +186,6 @@ async function onEmitMain(context: EmitContext) { const program = context.program; const sdkContext = await createPythonSdkContext(context); - const outputDir = context.emitterOutputDir; addDefaultOptions(sdkContext); const yamlMap = emitCodeModel(sdkContext); const parsedYamlMap = walkThroughNodes(yamlMap); @@ -255,83 +247,13 @@ async function onEmitMain(context: EmitContext) { await runPyodideGeneration(pyodide, "/output", yamlFilePath, commandArgs); await copyPyodideOutputToHost(context, pyodide, "/output"); } else { - const root = path.join(dirname(fileURLToPath(import.meta.url)), "..", ".."); - const yamlPath = await saveCodeModelAsYaml("python-yaml-path", parsedYamlMap); - - if (!program.compilerOptions.noEmit && !program.hasError()) { - // If emit-yaml-only mode, just copy YAML to output dir for batch processing - if (resolvedOptions["emit-yaml-only"]) { - if (!fs.existsSync(outputDir)) { - fs.mkdirSync(outputDir, { recursive: true }); - } - // Copy YAML to output dir with command args embedded - // Use unique filename to avoid conflicts when multiple specs share output dir - const configId = path.basename(yamlPath, ".yaml"); - const batchConfig = { yamlPath, commandArgs, outputDir }; - fs.writeFileSync( - path.join(outputDir, `.tsp-codegen-${configId}.json`), - JSON.stringify(batchConfig, null, 2), - ); - return; - } - // if not using pyodide and there's no venv, we try to create venv - if (!resolvedOptions["use-pyodide"] && !fs.existsSync(path.join(root, "venv"))) { - try { - await runPython3(path.join(root, "/eng/scripts/setup/install.py")); - await runPython3(path.join(root, "/eng/scripts/setup/prepare.py")); - } catch { - // if the python env is not ready, we use pyodide instead - resolvedOptions["use-pyodide"] = true; - } - } - - if (resolvedOptions["use-pyodide"]) { - // here we run with pyodide - const pyodide = await setupPyodideCall(root); - // create the output folder if not exists - if (!fs.existsSync(outputDir)) { - fs.mkdirSync(outputDir, { recursive: true }); - } - // mount output folder to pyodide - pyodide.FS.mkdirTree("/output"); - pyodide.FS.mount(pyodide.FS.filesystems.NODEFS, { root: outputDir }, "/output"); - // mount yaml file to pyodide - pyodide.FS.mkdirTree("/yaml"); - pyodide.FS.mount(pyodide.FS.filesystems.NODEFS, { root: path.dirname(yamlPath) }, "/yaml"); - await runPyodideGeneration( - pyodide, - "/output", - `/yaml/${path.basename(yamlPath)}`, - commandArgs, - ); - } else { - // here we run with native python - let venvPath = path.join(root, "venv"); - if (fs.existsSync(path.join(venvPath, "bin"))) { - venvPath = path.join(venvPath, "bin", "python"); - } else if (fs.existsSync(path.join(venvPath, "Scripts"))) { - venvPath = path.join(venvPath, "Scripts", "python.exe"); - } else { - reportDiagnostic(program, { - code: "pyodide-flag-conflict", - target: NoTarget, - }); - } - commandArgs["output-folder"] = outputDir; - commandArgs["tsp-file"] = yamlPath; - const commandFlags = Object.entries(commandArgs) - .map(([key, value]) => `--${key}=${value}`) - .join(" "); - const command = `${venvPath} ${root}/eng/scripts/setup/run_tsp.py ${commandFlags}`; - execSync(command); - - const excludePattern = blackExcludeDirs.join("|"); - execSync( - `${venvPath} -m black --line-length=120 --quiet --fast ${outputDir} --exclude "${excludePattern}"`, - ); - await checkForPylintIssues(outputDir, excludePattern); - } - } + await runNodeEmit({ + context, + parsedYamlMap, + commandArgs, + resolvedOptions, + runPyodideGeneration, + }); } } @@ -367,104 +289,3 @@ async function setupPyodideCallBrowser() { return pyodide; } - -async function setupPyodideCall(root: string) { - const pyodide = await loadPyodide({ - indexURL: path.dirname(fileURLToPath(import.meta.resolve("pyodide"))), - }); - const micropipLockPath = path.join(root, "micropip.lock"); - while (true) { - if (fs.existsSync(micropipLockPath)) { - try { - const stats = fs.statSync(micropipLockPath); - const now = new Date().getTime(); - const lockAge = (now - stats.mtime.getTime()) / 1000; - if (lockAge > 300) { - fs.unlinkSync(micropipLockPath); - } - } catch { - // ignore - } - } - try { - const fd = fs.openSync(micropipLockPath, "wx"); - // mount generator to pyodide - pyodide.FS.mkdirTree("/generator"); - pyodide.FS.mount( - pyodide.FS.filesystems.NODEFS, - { root: path.join(root, "generator") }, - "/generator", - ); - await pyodide.loadPackage("micropip"); - const micropip = pyodide.pyimport("micropip"); - await micropip.install(`emfs:/generator/dist/${PYGEN_WHEEL_FILENAME}`); - fs.closeSync(fd); - fs.unlinkSync(micropipLockPath); - break; - } catch { - await new Promise((resolve) => setTimeout(resolve, 1000)); - } - } - return pyodide; -} - -async function checkForPylintIssues(outputDir: string, excludePattern: string) { - const excludeRegex = new RegExp(excludePattern); - - const shouldExcludePath = (filePath: string): boolean => { - const relativePath = path.relative(outputDir, filePath); - const normalizedPath = relativePath.replace(/\\/g, "/"); - return excludeRegex.test(normalizedPath); - }; - - const processFile = async (filePath: string) => { - let fileContent = await fs.promises.readFile(filePath, "utf-8"); - const pylintDisables: string[] = []; - const lineEnding = fileContent.includes("\r\n") && os.platform() === "win32" ? "\r\n" : "\n"; - const lines: string[] = fileContent.split(lineEnding); - if (lines.length > 0) { - if (!lines[0].includes("line-too-long") && lines.some((line) => line.length > 120)) { - pylintDisables.push("line-too-long", "useless-suppression"); - } - if (!lines[0].includes("too-many-lines") && lines.length > 1000) { - pylintDisables.push("too-many-lines"); - } - if (pylintDisables.length > 0) { - fileContent = lines[0].includes("pylint: disable=") - ? [lines[0] + "," + pylintDisables.join(",")].concat(lines.slice(1)).join(lineEnding) - : `# pylint: disable=${pylintDisables.join(",")}${lineEnding}` + fileContent; - await fs.promises.writeFile(filePath, fileContent); - } - } - }; - - const collectPythonFiles = async (dir: string): Promise => { - if (shouldExcludePath(dir)) { - return []; - } - - const entries = await fs.promises.readdir(dir, { withFileTypes: true }); - - const promises = entries.map(async (entry) => { - const filePath = path.join(dir, entry.name); - - if (shouldExcludePath(filePath)) { - return []; - } - - if (entry.isDirectory()) { - return collectPythonFiles(filePath); - } else if (entry.name.endsWith(".py")) { - return [filePath]; - } - return []; - }); - - const results = await Promise.all(promises); - return results.flat(); - }; - - // Collect all Python files first, then process in parallel - const pythonFiles = await collectPythonFiles(outputDir); - await Promise.all(pythonFiles.map(processFile)); -} diff --git a/packages/http-client-python/emitter/src/node-runner.browser.ts b/packages/http-client-python/emitter/src/node-runner.browser.ts new file mode 100644 index 00000000000..bc548efdf8a --- /dev/null +++ b/packages/http-client-python/emitter/src/node-runner.browser.ts @@ -0,0 +1,33 @@ +// Browser stub for `node-runner.ts`. Swapped in via the `"browser"` field in +// `package.json`. The emitter's browser flow short-circuits before reaching +// `runNodeEmit`, so this stub is defense-in-depth — if it does get called, +// surface a clear diagnostic rather than a cryptic missing-module error. + +import type { EmitContext } from "@typespec/compiler"; +import { NoTarget } from "@typespec/compiler"; +import type { PyodideInterface } from "pyodide"; +import { PythonEmitterOptions, reportDiagnostic } from "./lib.js"; + +export interface RunNodeEmitArgs { + context: EmitContext; + parsedYamlMap: Record; + commandArgs: Record; + resolvedOptions: PythonEmitterOptions; + runPyodideGeneration: ( + pyodide: PyodideInterface, + outputFolder: string, + yamlFile: string, + commandArgs: Record, + ) => Promise; +} + +export async function runNodeEmit({ context }: RunNodeEmitArgs): Promise { + reportDiagnostic(context.program, { + code: "browser-runtime-load-failed", + target: NoTarget, + format: { + details: + "Native Python execution is not supported in the browser; the emitter must run in the in-browser Pyodide branch.", + }, + }); +} diff --git a/packages/http-client-python/emitter/src/node-runner.ts b/packages/http-client-python/emitter/src/node-runner.ts new file mode 100644 index 00000000000..47af1553517 --- /dev/null +++ b/packages/http-client-python/emitter/src/node-runner.ts @@ -0,0 +1,220 @@ +// Node-only execution path for the Python emitter. +// +// All direct usage of Node built-ins (`fs`, `os`, `path`, `url`, `child_process`) +// lives here so that the emitter entry can be bundled for the browser. A sibling +// `node-runner.browser.ts` stub is swapped in via the `"browser"` field in +// `package.json` when bundling with `platform: "browser"`. + +import { EmitContext, NoTarget } from "@typespec/compiler"; +import { execSync } from "child_process"; +import fs from "fs"; +import os from "os"; +import path, { dirname } from "path"; +import { loadPyodide, PyodideInterface } from "pyodide"; +import { fileURLToPath } from "url"; +import { blackExcludeDirs, PYGEN_WHEEL_FILENAME } from "./constants.js"; +import { saveCodeModelAsYaml } from "./external-process.js"; +import { PythonEmitterOptions, reportDiagnostic } from "./lib.js"; +import { runPython3 } from "./run-python3.js"; + +export interface RunNodeEmitArgs { + context: EmitContext; + parsedYamlMap: Record; + commandArgs: Record; + resolvedOptions: PythonEmitterOptions; + runPyodideGeneration: ( + pyodide: PyodideInterface, + outputFolder: string, + yamlFile: string, + commandArgs: Record, + ) => Promise; +} + +export async function runNodeEmit({ + context, + parsedYamlMap, + commandArgs, + resolvedOptions, + runPyodideGeneration, +}: RunNodeEmitArgs): Promise { + const program = context.program; + const outputDir = context.emitterOutputDir; + const root = path.join(dirname(fileURLToPath(import.meta.url)), "..", ".."); + const yamlPath = await saveCodeModelAsYaml("python-yaml-path", parsedYamlMap); + + if (program.compilerOptions.noEmit || program.hasError()) { + return; + } + + // If emit-yaml-only mode, just copy YAML to output dir for batch processing + if (resolvedOptions["emit-yaml-only"]) { + if (!fs.existsSync(outputDir)) { + fs.mkdirSync(outputDir, { recursive: true }); + } + // Copy YAML to output dir with command args embedded + // Use unique filename to avoid conflicts when multiple specs share output dir + const configId = path.basename(yamlPath, ".yaml"); + const batchConfig = { yamlPath, commandArgs, outputDir }; + fs.writeFileSync( + path.join(outputDir, `.tsp-codegen-${configId}.json`), + JSON.stringify(batchConfig, null, 2), + ); + return; + } + + // if not using pyodide and there's no venv, we try to create venv + if (!resolvedOptions["use-pyodide"] && !fs.existsSync(path.join(root, "venv"))) { + try { + await runPython3(path.join(root, "/eng/scripts/setup/install.py")); + await runPython3(path.join(root, "/eng/scripts/setup/prepare.py")); + } catch { + // if the python env is not ready, we use pyodide instead + resolvedOptions["use-pyodide"] = true; + } + } + + if (resolvedOptions["use-pyodide"]) { + // here we run with pyodide + const pyodide = await setupPyodideCall(root); + // create the output folder if not exists + if (!fs.existsSync(outputDir)) { + fs.mkdirSync(outputDir, { recursive: true }); + } + // mount output folder to pyodide + pyodide.FS.mkdirTree("/output"); + pyodide.FS.mount(pyodide.FS.filesystems.NODEFS, { root: outputDir }, "/output"); + // mount yaml file to pyodide + pyodide.FS.mkdirTree("/yaml"); + pyodide.FS.mount(pyodide.FS.filesystems.NODEFS, { root: path.dirname(yamlPath) }, "/yaml"); + await runPyodideGeneration(pyodide, "/output", `/yaml/${path.basename(yamlPath)}`, commandArgs); + return; + } + + // here we run with native python + let venvPath = path.join(root, "venv"); + if (fs.existsSync(path.join(venvPath, "bin"))) { + venvPath = path.join(venvPath, "bin", "python"); + } else if (fs.existsSync(path.join(venvPath, "Scripts"))) { + venvPath = path.join(venvPath, "Scripts", "python.exe"); + } else { + reportDiagnostic(program, { + code: "pyodide-flag-conflict", + target: NoTarget, + }); + return; + } + commandArgs["output-folder"] = outputDir; + commandArgs["tsp-file"] = yamlPath; + const commandFlags = Object.entries(commandArgs) + .map(([key, value]) => `--${key}=${value}`) + .join(" "); + const command = `${venvPath} ${root}/eng/scripts/setup/run_tsp.py ${commandFlags}`; + execSync(command); + + const excludePattern = blackExcludeDirs.join("|"); + execSync( + `${venvPath} -m black --line-length=120 --quiet --fast ${outputDir} --exclude "${excludePattern}"`, + ); + await checkForPylintIssues(outputDir, excludePattern); +} + +async function setupPyodideCall(root: string): Promise { + const pyodide = await loadPyodide({ + indexURL: path.dirname(fileURLToPath(import.meta.resolve("pyodide"))), + }); + const micropipLockPath = path.join(root, "micropip.lock"); + while (true) { + if (fs.existsSync(micropipLockPath)) { + try { + const stats = fs.statSync(micropipLockPath); + const now = new Date().getTime(); + const lockAge = (now - stats.mtime.getTime()) / 1000; + if (lockAge > 300) { + fs.unlinkSync(micropipLockPath); + } + } catch { + // ignore + } + } + try { + const fd = fs.openSync(micropipLockPath, "wx"); + // mount generator to pyodide + pyodide.FS.mkdirTree("/generator"); + pyodide.FS.mount( + pyodide.FS.filesystems.NODEFS, + { root: path.join(root, "generator") }, + "/generator", + ); + await pyodide.loadPackage("micropip"); + const micropip = pyodide.pyimport("micropip"); + await micropip.install(`emfs:/generator/dist/${PYGEN_WHEEL_FILENAME}`); + fs.closeSync(fd); + fs.unlinkSync(micropipLockPath); + break; + } catch { + await new Promise((resolve) => setTimeout(resolve, 1000)); + } + } + return pyodide; +} + +async function checkForPylintIssues(outputDir: string, excludePattern: string) { + const excludeRegex = new RegExp(excludePattern); + + const shouldExcludePath = (filePath: string): boolean => { + const relativePath = path.relative(outputDir, filePath); + const normalizedPath = relativePath.replace(/\\/g, "/"); + return excludeRegex.test(normalizedPath); + }; + + const processFile = async (filePath: string) => { + let fileContent = await fs.promises.readFile(filePath, "utf-8"); + const pylintDisables: string[] = []; + const lineEnding = fileContent.includes("\r\n") && os.platform() === "win32" ? "\r\n" : "\n"; + const lines: string[] = fileContent.split(lineEnding); + if (lines.length > 0) { + if (!lines[0].includes("line-too-long") && lines.some((line) => line.length > 120)) { + pylintDisables.push("line-too-long", "useless-suppression"); + } + if (!lines[0].includes("too-many-lines") && lines.length > 1000) { + pylintDisables.push("too-many-lines"); + } + if (pylintDisables.length > 0) { + fileContent = lines[0].includes("pylint: disable=") + ? [lines[0] + "," + pylintDisables.join(",")].concat(lines.slice(1)).join(lineEnding) + : `# pylint: disable=${pylintDisables.join(",")}${lineEnding}` + fileContent; + await fs.promises.writeFile(filePath, fileContent); + } + } + }; + + const collectPythonFiles = async (dir: string): Promise => { + if (shouldExcludePath(dir)) { + return []; + } + + const entries = await fs.promises.readdir(dir, { withFileTypes: true }); + + const promises = entries.map(async (entry) => { + const filePath = path.join(dir, entry.name); + + if (shouldExcludePath(filePath)) { + return []; + } + + if (entry.isDirectory()) { + return collectPythonFiles(filePath); + } else if (entry.name.endsWith(".py")) { + return [filePath]; + } + return []; + }); + + const results = await Promise.all(promises); + return results.flat(); + }; + + // Collect all Python files first, then process in parallel + const pythonFiles = await collectPythonFiles(outputDir); + await Promise.all(pythonFiles.map(processFile)); +} diff --git a/packages/http-client-python/emitter/src/pyodide-loader.browser.ts b/packages/http-client-python/emitter/src/pyodide-loader.browser.ts new file mode 100644 index 00000000000..e0a7cde43e8 --- /dev/null +++ b/packages/http-client-python/emitter/src/pyodide-loader.browser.ts @@ -0,0 +1,49 @@ +// Browser stub for `pyodide-loader.ts`. Loads pyodide via a `